Another newbie question
| From: | Pete Holsberg | Date: | Mon, 06 Sep 2004 21:50:15 +0000 |
| Subject: | Another newbie question | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-36075@lists.php.net to get a copy of this message | ||
The following code results in the error message "Couldn't execute query."
-----------
<?php
/* Program: ShowDir.php
* Desc: Displays results of the search.
*/
?>
<html>
<head><title>Search Results</title></head>
<body topmargin="0" marginheight="0">
<?php
include("login.inc");
$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?
Thanks.