R
Rae2
Guest
Every time I try to get a PHP variable into a mysql statement, the results come up blank:
$sql = "SELECT * FROM restaurants WHERE zip = '$browseBy'";
or
$sql ='SELECT * FROM restaurants where zip="'. ($_GET['mode']=='browseBy') .'"';
Now, mind you - I've used MANY different ways to insert the variable into the statement... all getting the same result.... nothing.
Also, I have tested just the variable itself with the echo statement which works fine.
Thanks in advance!
Yes and yes.
When I do the same string, but without a variable and just type 'WHERE zip = 19363' it works fine to pull up all the records with matching zips.
Thanks everyone, however still not working.
JR, I did try your syntax (as well as many others) with the same results of a blank table.
Steve, $browseBy is being brought in from a drop down on another php page.
As I mentioned, when I just simply echo "$browseBy" it prints '19363', but when I try to pull that variable into the mysql statement, it brings nothing.
$sql = "SELECT * FROM restaurants WHERE zip = '$browseBy'";
or
$sql ='SELECT * FROM restaurants where zip="'. ($_GET['mode']=='browseBy') .'"';
Now, mind you - I've used MANY different ways to insert the variable into the statement... all getting the same result.... nothing.
Also, I have tested just the variable itself with the echo statement which works fine.
Thanks in advance!
Yes and yes.
When I do the same string, but without a variable and just type 'WHERE zip = 19363' it works fine to pull up all the records with matching zips.
Thanks everyone, however still not working.
JR, I did try your syntax (as well as many others) with the same results of a blank table.
Steve, $browseBy is being brought in from a drop down on another php page.
As I mentioned, when I just simply echo "$browseBy" it prints '19363', but when I try to pull that variable into the mysql statement, it brings nothing.