turpentyne Posted October 3, 2010 Share Posted October 3, 2010 I'm trying to pull data to display on a page and I seem to be missing something in the where clause. I've verified I've named the right table, column and that a record exists. The caps are the same. The spelling is the same. I get this error: Unknown column '$id' in 'where clause' $id = $_GET['id']; require ('databaseconnect.php'); $result = mysql_query('SELECT * FROM descriptors WHERE $id = plant_id'); if (!$result) { die(mysql_error()); } while ($row = mysql_fetch_array($result)) { //etc. etc. Link to comment https://forums.phpfreaks.com/topic/215016-unknown-column-name-in-where-clause/ Share on other sites More sharing options...
trq Posted October 3, 2010 Share Posted October 3, 2010 Variables are not interpolated within single quotes. Put your query within double quotes. Link to comment https://forums.phpfreaks.com/topic/215016-unknown-column-name-in-where-clause/#findComment-1118453 Share on other sites More sharing options...
turpentyne Posted October 3, 2010 Author Share Posted October 3, 2010 cool! thanks! Link to comment https://forums.phpfreaks.com/topic/215016-unknown-column-name-in-where-clause/#findComment-1118456 Share on other sites More sharing options...
alanwake Posted October 16, 2010 Share Posted October 16, 2010 hello i've got the same problem... MySQL client version: 5.1.41 here's my code: $q="SELECT * FROM gallery_album WHERE name = BMWcars"; $result = mysql_query($q)or die("Query failed with error: ".mysql_error()); where gallery_album is my table name is a column BMWcars is the name of an album that i get before in the page [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/215016-unknown-column-name-in-where-clause/#findComment-1122720 Share on other sites More sharing options...
trq Posted October 17, 2010 Share Posted October 17, 2010 $q="SELECT * FROM gallery_album WHERE name = 'BMWcars'"; Link to comment https://forums.phpfreaks.com/topic/215016-unknown-column-name-in-where-clause/#findComment-1122852 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.