This topic is locked

Using Session Variable in SQL Query

6/10/2009 5:06:41 PM
PHPRunner General questions
D
DigitalDean8 author

I would like to setup an event where based on a table query that checks to see if a record already exists by comparing it to a SESSION variable. However I am not getting the syntax correct. Can anyone assist? This is what I am trying to do:
$strSQLExists = "select * from carreview where ReviewerName='$_SESSION["ReviewerName"''";
What is wrong with this syntax?

A
alang 6/10/2009

Try:
$strSQLExists = "select from carreview where ReviewerName='{$_SESSION["ReviewerName"]}'";
or:
$strSQLExists = "select
from carreview where ReviewerName='".$_SESSION["ReviewerName"]."'";