Ozn Ozi Ozn Ozi - 12 days ago 5
PHP Question

sql/php syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting

I got error on line 16 in myphp page which is;

$result = mysql_query("update Users set lat='$lat',lon='$lng' where username=$_SESSION['username']");

Answer

You lost track of all needed ' and additionally forgot to quote username value. So instead of

$result = mysql_query("update Users set lat='$lat',lon='$lng' where username=$_SESSION['username']");

do this in more clean manner:

$result = mysql_query( "update Users set lat='$lat',lon='$lng' where username='" . $_SESSION['username'] . "'");

or even better:

$query = sprintf("update Users set lat='%s',lon='%s' where username=%s"), 
         $lat, $lng, $_SESSION['username']);
$result = mysql_query($query);

BTW: switch to MYSQLi or PDO as MYSQL extension is deprecated, no new code should touch it.