DATABASE SEARCH
Posted: Fri Feb 26, 2010 10:56 am
ok I can connect to my database and pull info from it. I'm trying to search my database (using phpMyAdmin) in DB business, Table rest, and Field Cost. Im looking for "low" in that feild. When i run the code below it gives me this statement.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'Low\' LIMIT 0, 30' at line 1
$db_host = 'localhost';
$db_user = 'root';
$db_pass = 'blabla';
$db_db = 'business';
$db_table = 'rest';
$db_link = mysql_connect($db_host, $db_user, $db_pass)
or die('MySQl Connection Error:'.mysql_error());
mysql_select_db($db_db)
or die('MySQL Error: Cannot select table');
$XX = "No Record Found";
$query = "SELECT * FROM `rest` WHERE `Cost` LIKE \'Low\' LIMIT 0, 30 ";
$result = mysql_query("$query") or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo $row[Name] . " " . $row[Style];
echo "<br />";
}
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'Low\' LIMIT 0, 30' at line 1
$db_host = 'localhost';
$db_user = 'root';
$db_pass = 'blabla';
$db_db = 'business';
$db_table = 'rest';
$db_link = mysql_connect($db_host, $db_user, $db_pass)
or die('MySQl Connection Error:'.mysql_error());
mysql_select_db($db_db)
or die('MySQL Error: Cannot select table');
$XX = "No Record Found";
$query = "SELECT * FROM `rest` WHERE `Cost` LIKE \'Low\' LIMIT 0, 30 ";
$result = mysql_query("$query") or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo $row[Name] . " " . $row[Style];
echo "<br />";
}