[RESOLVED] Select * works but not individual columns
could you please help me figure out why selecting all works but not individual columns? When selecting individual columns I get an empty result set.
Code is below.
I greatly appreciate the help, i have been looking at this for hours.
$sql="SELECT * FROM theDatabase Where isbn = " . $_POST['isbn'];
//returns empty set
//$sql="SELECT index, parent, user, primary, review, spoilers FROM theDatabase Where isbn = " . $_POST['isbn'];
$result = mysql_query($sql, $connection);
$reviews = array();
while ($row = mysql_fetch_array($result))
$review['index'] = $row['index'];
$review['parent'] = $row['parent'];
$review['user'] = $row['user'];
$review['primary'] = $row['primary'];
$review['review'] = $row['review'];
$review['spoilers'] = $row['spoilers'];
Try quoting the column names -- in MySQL typically done with the `back-tick` character -- as some of them may be reserved words.
PS: You can help the debugging by checking to see if the result of your mysql_query() is false, and if so log or output an error with info from mysql_error().
PPS: The PHP MySQL extension is now deprecated, and you should really be using either the MySQLi extension or even the PDO extension.
That was it, thank you for the help. index and primary are reserved words.
I will do as you advise and look into MySQLi. Thank you again
when you naming columns try to avoid reserve words like index, primary, user....it will help
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)