PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
uberpolak
Forum Contributor
Posts: 261 Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar
Post
by uberpolak » Mon Jan 20, 2003 4:36 pm
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...
mydimension
Moderator
Posts: 531 Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:
Post
by mydimension » Mon Jan 20, 2003 4:43 pm
show us the surrounding code as the error usually is almost never on the line given in the error.
uberpolak
Forum Contributor
Posts: 261 Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar
Post
by uberpolak » Mon Jan 20, 2003 6:31 pm
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);
?>
mydimension
Moderator
Posts: 531 Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:
Post
by mydimension » Mon Jan 20, 2003 11:11 pm
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
uberpolak
Forum Contributor
Posts: 261 Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar
Post
by uberpolak » Tue Jan 21, 2003 5:57 pm
thanks, that fixes it up nicely
evilcoder
Forum Contributor
Posts: 345 Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia
Post
by evilcoder » Tue Jan 21, 2003 8:13 pm
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'