In my php I make this query
$sql = "SELECT * FROM session WHERE sessionid = '$_SESSION["id"]';";
which results in an error
Parse error: syntax error, unexpected '"', expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /opt/lampp/htdocs/Chore-Champs/index.php on line 6
Obviously there is something wrong with how I'm nesting the quotes, so I've tried different ways, including
$sql = "SELECT * FROM session WHERE sessionid = " . $_SESSION['id'] . ";";
this still results in the same error.
Normally the first method would work with normal variables such as $username
, but I guess that session variables are handled differently. What's the correct way to write this query?