# Having trouble with PHP/MySQL



## raesquared (Aug 26, 2009)

I am having trouble having a PHP variable work properly in a mysql statement. 

$browseBy is my variable (it is brought in from another php page's drop down menu). 

So if I echo $browseBy - the results print on the page with no problem. 
However, I've tried various different methods of posting the mysql statement - the table is always showing up blank. 

$sql = "SELECT * FROM restaurants WHERE zip = $browseBy"; 
$sql ='SELECT * FROM restaurants where zip="'. ($_GET['mode']=='browseBy') .'"'; 
$sql = "SELECT * FROM `restaurants` where `zip`= '".$browseBy."'"; 
(these statements all give me blank results)

However, if I replace the variable with the results themselves (ie typing in the zip code 19363 instead of having $browseBy bring it in), it works fine. 

$sql = "SELECT * FROM restaurants WHERE zip = 19363"; (works fine)


----------

