I am having a problem with PHP (am very inexperienced with it) and I am getting the below error. Could anyone help me find the cause of the below error.
Parse error: syntax error, unexpected ” (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/jsnow/projects/one/htdocs/edit-exec.php on line 30
My Code:
$dbconn = mysql_select_db(APP_DB);
if(!$dbconn)
{
die("ERROR SELECTING DB");
}
$query = "SELECT * FROM users WHERE users_id='$_SESSION['SESS_USER_ID']'";
$result = @mysql_query($query);
if($result) {
header("location: success-register.php");
exit();
}else {
die("Query failed");
}
I am not sure if its something obvious but I cant see it.
Any help would be very appreciative.
The above code has not been very well written.
You are probably better off using something like PDO instead of the below.
However the problem is most likely with the ‘ inside of $query.
Try the below.
That would fix the code but I would recommend using something like the below instead (will add params later and satanize ensuring protection from sql injection):