Accepting PHP variables but not in SQL
Posted: Sun Jul 04, 2010 12:22 pm
I have a simple SQL code that is not working, but I have confirmed that the variables are being captured from the form ($city = $_POST["city"]; echo $city;). If I force a constant in - WHERE City ='ny' , it works, but not when I use a variable. It's been a while since I've used PHP and MySQL. What am I missing here?
Here's the code:
Here's the code:
Code: Select all
<?php
$city = $_POST["city"]; echo $city;
$link = mysql_connect("localhost", "xxxxxxxx", "xxxxxxx") or die ("Access To DB Error"); // Sets up the link = server, username and pw.
mysql_select_db("rr_test", $link) or die ("DB not selected");
$Res = "SELECT * FROM general WHERE City = $city";
$Results = mysql_query($Res) or die ("No Data Selected");
?>