Syntax issue using mysql select with where clause


Ok I am doing something stupid.

$result = mysql_query('SELECT * FROM `main` WHERE `recnbr` = 10 ');

works exactly as expected, but$recnum = 10; $result = mysql_query('SELECT * FROM `main` WHERE `recnbr` = $recnum '); returns

Error performing query:Unknown column ‘$recnum’ in ‘where clause’
when I would expect the same result, what am I doing wrong?


$result = mysql_query('SELECT * FROM main WHERE recnbr = '.$recnum); [/php]

Or you could do

$result = mysql_query(“SELECT * FROM main WHERE recnbr = $recnum”); [/php]

Note the use of the SINGLE quotes and DOUBLE quotes.


Thank you!


My Pleasure. 8)