The following code results in the error message "Couldn't execute query."

  /* Program: ShowDir.php
   * Desc:    Displays results of the search.
<head><title>Search Results</title></head>
<body topmargin="0" marginheight="0">

  $connection = mysql_connect($host,$user,$password)
       or die ("Couldn't connect to server");

  $db = mysql_select_db($database,$connection)
       or die ("Couldn't select database");

$sql = "SELECT * FROM $table ";
$sql .= "WHERE `LastName` LIKE $search_string ";
$sql .= "OR `FirstName` LIKE $search_string ";
$sql .= "OR `Spouse` LIKE $search_string ";
$sql .= "OR `Street` LIKE $search_string ";
$sql .= "OR `Email` LIKE $search_string LIMIT 0, 30 ";
$sql .= "ORDER BY Street, HouseNum, LastName";

  $result = mysql_query($sql)
       or die ("Couldn't execute query.");


Why is that?

Also, how do I make LIKE insensitive to case?

And finally, how do I use the % wildcard with a variable?


PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to