Parse error: syntax error, unexpected '–' (T_STRING) in PHP [duplicate] - syntax-error

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 2 years ago.
I am getting a Parse error: syntax error, unexpected '–' (T_STRING) in the following line:
$lbm = ((0.407 * $weightkg) + (0.267 * $heightcm) - 19.2) / 0.453592;
From what I see, I am using a subtraction sign and not a hyphen. Other than that, I don't know what could be wrong. Anyone know how to fix this?

Well, the character you pasted into the title is definitely an en-dash rather than a minus symbol(a) so PHP is rightly complaining about it.
The line in the main body of your question is a hyphen so either you've typed in in differently or that's not the line where the error is (PHP can sometimes be a bit iffy as to where it reports errors, so you may want to look on the few lines immediately around the one it reports the error to be on).
(a) Which is actually distinct from a hyphen, at least in typography, so you may want to beware of lunatic typographers coming around to beat you up for your transgressions :-)

Related

OpenSCAD parser error in the *middle* of a comment when last line accidentally uncommented?

I have the following segment of comment in my code file (the last line is intentionally missing the slash characters - that the error):
// * Cube Back Text from Méi guī
// 一颗 心 怕 摔倒 打破
//"yī kē xīn pà shuāi dǎo dǎ pò"
// "It's the heart afraid of breaking"
// 不敢 起舞 欢 歌
// "bù gǎn qǐwǔ huāngē"
// "that never learns to dance."
不敢起舞欢歌 (dance)
But the red error dot appears on the second character of the second line (second slash of the line "// * Cube Back Text from Méi guī".
Stranger, if I remove various quotes in the comment, the character that is hilited changes.
I assume this has something to do with a recursive structure somewhere in the parser that is continuing to parse the quotes inside the comment itself and ultimately figures out where to signal the error.
I suppose this is a bug ("semi-bug") that I should post to the GitHub list - to completely ignore anything past the second slash on a commented line, or some other change so that the error tag shows up on the line where the error actually is?
As it is, I futzed around about 10 minutes wondering if OpenSCAD just didn't like files longer than 575 lines.
I get the same problem when I try your example or modify it slightly but it worked perfectly when I replaced everything with random Latin characters so I think the bug has a lot to do with the Chinese ideographs you used.
In any case, I only copied the small sample you gave so it probably have nothing to do with the length of the file.

invalid syntax in generating a variable in Stata

While creating this variable in stata14 I've got an error (198)
this is the variable that I want to generate:
g ncskew =(-(([_n])*([_n-1])^(1.5)*(sum(returns^3))))///
/(([_n-1])*([_n-2])*(sum(returns^2)^(1.5))
It is quite a puzzle but I think that the brackets are well placed.
Any help or advice would be appreciated.
The problem that jumps out at my eye is that the /// at the end of the first line is not preceded by any whitespace. That is a syntax error.
The other problem is that you have 13 opening parentheses ( and just 12 closing parentheses ). Is this your actual code or a mis-typed copy?
Whether that are the only problems with your code, I cannot say. If that is your actual code, fix that first and see what happens.

Parse error: syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:... on line 22

I want to update a row in a table for my project, I'm copying a syntax I saw somewhere else here however, I think my problem comes when I try updating where ApplicantID is equal to $_SESSION["ID"].
I get this error
Parse error: syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\...\InsertPData.php on line 22
here is the php along side the SQL:
<?php
include_once'dbconnect.php';
session_start();
function INSERT()
{
$Name=$_POST['name'];
$Relation=$_POST['Relation'];
$Email=$_POST['Email'];
$Address=$_POST['Address'];
$Postcode=$_POST['Postcode'];
$Mobile_Number=$_POST['Mobile_Number'];
$Home_Number=$_POST['Home_Number'];
$INSERT="UPDATE Applicants
SET ParentName='$Name',
Relationtoapplicant='$Relation',
ParentEmail='$Email',
ParentAddress='$Address',
ParentPostcode='$Postcode',
ParentMobile='$Mobile_Number',
ParentHome='$Home_Number',
WHERE ApplicantID=$_SESSION["ID"] "; #THIS IS LINE 22
$data=mysql_query($INSERT) or die(mysql_error());
if($data)
{
echo "Parents/Gauridan details hav been entered";
}
else print "error";
}
INSERT()
?>
I've already searched for a solution to this but haven't found something where the user is using a session thing. Thank you.
This is why an IDE with syntax highlighting is helpful. StackOverflow uses syntax highlighting on code blocks as well and actually already gives you the answer based on your code:
$INSERT="UPDATE Applicants
WHERE ApplicantID=$_SESSION["ID"] ";
See how ID is suddenly black instead of dark red? That's because you are terminating the string there. The double quotes should either be escaped or replaced with single quotes, like:
$INSERT="UPDATE Applicants
WHERE ApplicantID=$_SESSION[\"ID\"] ";
Or
$INSERT="UPDATE Applicants
WHERE ApplicantID=$_SESSION['ID'] ";
See how the ID bit stays dark red? This is because now your string is not suddenly terminated.
Also, please do not use mysql_ functions anymore. They have been deprecated since 2013 and are currently not even a part of PHP anymore. So if you'd update your PHP to the latest version, this code would not work. On top of that, this code is vulnerable to SQL injection attacks.
Also see Why shouldn't I use mysql_* functions in PHP? and How can I prevent SQL-injection in PHP?.

BigQuery Line numbering

Maybe i'm missing something, but does anyone know how the debugging line numbering works in BigQuery?
I get an error like this:
Failed to save view. 2.196 - 2.226: Ambiguous column name eventcode.
and I'm not sure what the address 2.196-2.226 means. Specifically, what does the decimal signify? The second line of my query is very short (just SELECT *), so I don't think the numbers after the decimal indicate a character range?
Anyway -- I can't find any info for it in the docs, so any help here would be great
Line counting is most like shifted by 1 so it is actually line number #1 (not #2)
196 - 226 points to char range on that line with piece of code that introduces ambiquity - just the second piece (that has already existing aliac or column name for it)
Somehow for some first lines line numbering is incremented by 1 - it can be a bug on BQ UI side.
Btw, I noticed same strange behaviour in CodeMirror BQ UI is using, so it can be CodeMirror's bug too

why am I getting an error in the identification division?

The following code :
IDENTIFICATION DIVISION.
PROGRAM-ID. tester.
PROCEDURE DIVISION.
greet_program.
DISPLAY "HELLO WORLD !".
STOP RUN.
produces a compiler error which says : Error: syntax error, unexpected WORD, expecting PROGRAM_ID
I am unable to spot the error. Where is it ?
The errors with the program are listed here at ideone
You are compiling using the option of a traditional "fixed" Cobol layout.
That means you need to start each line with seven blanks.
You should have asked yourself why the first error messages referred to column seven. You could also have found some sample Cobol cobde and compare it to yours. Other people you can find with Google who've done the same thing.