Help with Select statement in PHP code please
Posted: Sun Mar 29, 2009 12:19 pm
Hi there:
I cannot get a variable to evaluate properly in a select statement. I have confirmed that the variable $center_ref is getting assigned a value of 1 by an echo statement. I have also confirmed that when putting the value of the variable directly in the code I get the desired results. Here is the code snippet:
while ($games = mysql_fetch_array($game)) {
$id = $games['id'];
$date = $games['date'];
$time = $games['time'];
$hometeam = $games['hometeam'];
$visitingteam = $games['visitingteam'];
$field = $games['field'];
$center_ref = $games['center_ref']; (Following is the part I need help with)
$pick1= @mysql_query('Select firstname, lastname FROM refs
WHERE id="$center_ref"'); (This does NOT work)
$pick1= @mysql_query('Select firstname, lastname FROM refs
WHERE id=1; (This works)
Any help would be appreciated.
Thank you in advance,
Dave
I cannot get a variable to evaluate properly in a select statement. I have confirmed that the variable $center_ref is getting assigned a value of 1 by an echo statement. I have also confirmed that when putting the value of the variable directly in the code I get the desired results. Here is the code snippet:
while ($games = mysql_fetch_array($game)) {
$id = $games['id'];
$date = $games['date'];
$time = $games['time'];
$hometeam = $games['hometeam'];
$visitingteam = $games['visitingteam'];
$field = $games['field'];
$center_ref = $games['center_ref']; (Following is the part I need help with)
$pick1= @mysql_query('Select firstname, lastname FROM refs
WHERE id="$center_ref"'); (This does NOT work)
$pick1= @mysql_query('Select firstname, lastname FROM refs
WHERE id=1; (This works)
Any help would be appreciated.
Thank you in advance,
Dave