Query Looks For Column - Very Peculiar


I am finding a very strange result from a query I am trying to perform.

The roomname is office (.php?roomname=office)

The word office is echoed as per the first echo of the below code. However instead of searching the column ‘room’ for the word ‘office’ in table furniture_groups it returns an message saying that the column ‘office’ is not in the table. However it shouldn’t be searching for a column, it should querying the column called room.

Any suggestions please?


$roomname = mysql_real_escape_string($_GET['roomname']);

echo $roomname;

   $sql = "SELECT * FROM furniture_groups WHERE room = $roomname";
    $res = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_assoc($res); // no need to loop since you are retrieving only one row

echo $row['long_name'];


You must put $roomname in single quotes.