Page 1 of 1
Correct Syntax?
Posted: Mon Dec 30, 2002 10:54 am
by eggoz
I have this query that calls all fields from a table called testtable, where column two should equal $value. $value is a value that I passed from the previous page. This is what I have right now:
Code: Select all
$record = mysql_query ( SELECT * FROM testtable.* WHERE two = $value );
Where am I going wrong?
Posted: Mon Dec 30, 2002 11:10 am
by Rob the R
You are missing some double-quotes and have an extraneous asterisk. Try this:
Code: Select all
<?php
$result = mysql_query ("SELECT * FROM testtable WHERE two = '$value' " );
?>
I put single-quotes around the $value in the query; this is assuming that the column TWO in your table is character. If it is numeric, the single-quotes around $value are not needed.
Also note that you'll have to use
mysql_fetch_array() to get at the records (rows) this query returns.
mysql_query() just returns a resource and not the actual record set of the query.