Hello! I have a problem trying to search on one of my db tables which uses ...
phpMyAdmin (Version information: 3.3.9) and Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $
PHP extension: mysql
I am using the following php code to do the search...
and receive the following error messagePHP Code:OpenDB();
$element = $_REQUEST["element"];
$criteria = mysql_real_escape_string($_REQUEST["criteria"]);
switch ($element)
{
case "datetime":
$sql = "SELECT * FROM `vehicles` WHERE datetime LIKE '%".$criteria."%'";
$row = mysql_query($sql) or die(mysql_error());
break;
case "fullname";
$sql = "SELECT * FROM `vehicles` WHERE fullname LIKE '%".$criteria."%'";
$row = mysql_query($sql) or die(mysql_error());
break;
case "make":
$sql = "SELECT * FROM `vehicles` WHERE make LIKE '%".$criteria."%'";
$row = mysql_query($sql) or die(mysql_error());
break;
case "year":
$sql = "SELECT * FROM `vehicles` WHERE year LIKE '%".$criteria."%'";
$row = mysql_query($sql) or die(mysql_error());
break;
case "suburb":
$sql = "SELECT * FROM `vehicles` WHERE suburb LIKE '%".$criteria."%'";
$row = mysql_query($sql) or die(mysql_error());
}
I am truly perplexed! Can anyone see the wood for the trees?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 '' at line 1![]()


Reply With Quote




Bookmarks