Can't search a field HELP!

admin

Administrator
Staff member
I just can't figure this out. Part of the script can be seen below. I am trying to search the "city" field, but it won't work. The "city" field is set at varchar(15) if it means anything. I've got a "state" field (varchar(15) also) that for some reason gets the same "couldn't execute query" error too. It must be noted that I have no problems with this script searching char and int fields!

$sql = "SELECT
*
FROM $table_name
WHERE city = $citysearch
ORDER BY id
";

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

while ($row = mysql_fetch_array($result)) {

$id = $row['id'];
$city = $row['city'];

$display_block .= "
ID:<a href=http://www.phpbuilder.com/board/archive/index.php/\"$id.html\">$id</a><BR>
City: $city <BR>
";

}
?>


<HEAD>
<TITLE>SEARCH RESULTS</TITLE>
</HEAD>
<BODY>
<H1>SEARCH RESULTS</H1>
<? echo "$display_block"; ?>
</BODY>
 
Back
Top