Page 1 of 1
Meaning of error message
Posted: Mon Jan 20, 2003 4:36 pm
by uberpolak
I'm getting this error message, can somebody tell me what it means?
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
It then goes on to say the path to the file and the line number. This is the line of code it specifies:
Code: Select all
<?php
$lesval = $_POST['fname'] . " " . $_POST['lname'];
?>
I don't see what the problem is...
Posted: Mon Jan 20, 2003 4:43 pm
by mydimension
show us the surrounding code as the error usually is almost never on the line given in the error.
ok...
Posted: Mon Jan 20, 2003 6:31 pm
by uberpolak
Here is the code within the same branch of an if statement, thanks in advance for helping me out.
Code: Select all
<?php
$con = mysql_connect("XXXX","XXXX","XXXX");
mysql_select_db("XXXX");
if ($_POST['notes']) {$notes = $_POST['notes'];}
else {$notes = "";}
if (file_exists("../data/" . $_POST['lname'] . $_POST['fname'] . ".dat") != true)
{
$zork = fopen("../data/" . $_POST['lname'] . $_POST['fname'] . ".dat","w");
fputs($zork,$_POST['areacode'] . "-" . $_POST['p1'] . "-" . $_POST['p2'] . " " . $notes);
fclose($zork);
mysql_query("UPDATE stats SET num_people += 1 WHERE month = '" . $month . "',$con) or die(mysql_error());
}
$lesval = $_POST['fname'] . " " . $_POST['lname'];
$wasles = mysql_fetch_row(mysql_query("SELECT " . $lestime . " FROM " . $month . " WHERE day=" . $_POST['d'],$con)) or die(mysql_error());
mysql_query("UPDATE " . $month . " SET " . $lestime . "='" . $lesval . "' WHERE day=" . $_POST['d'],$con);
if ($wasles[0] == "")
{
$mstats = mysql_fetch_row(mysql_query("SELECT lessons, num_people FROM stats WHERE month = '" . $month . "',$con)) or die(mysql_error());
mysql_query("UPDATE stats SET lessons += 1 WHERE month ='" . $month . "'",$con) or die(mysql_error());
}
mysql_close($con);
?>
Posted: Mon Jan 20, 2003 11:11 pm
by mydimension
this is where code editors that highlight syntax come in very useful. even with the highlighting that this forum does it is easy to spot the error. you have to many quotes on this line:
Code: Select all
mysql_query("UPDATE stats SET num_people += 1 WHERE month = '" . $month . "',$con) or die(mysql_error());
change it to this:
Code: Select all
mysql_query("UPDATE stats SET num_people += 1 WHERE month = '$month'",$con) or die(mysql_error());
the difference should be clear in the way the code is colored
thanks
Posted: Tue Jan 21, 2003 5:57 pm
by uberpolak
thanks, that fixes it up nicely
Posted: Tue Jan 21, 2003 8:13 pm
by evilcoder
future reference, when creating variables that contain SQL commands, don't use them like echo's.
eg WHERE raw = " . $raw . "
just define is as: WHERE raw = '$raw'