> > Why isn't this working for searching? > > // Run query on submitted values. Store results in $SESSION and redirect > to restaurants.php $sql = "SELECT name, address, inDate, inType, > notes, critical, cviolations, noncritical FROM restaurants, inspections > WHERE restaurants.name <> '' AND restaurant.ID = inspection.ID"; if > ($searchName) { $sql .= "AND restaurants.name LIKE '%". > mysql_real_escape_string($name) ."%' "; if(count($name2) == 1) { > $sql .= "AND restaurants.name LIKE '%". > mysql_real_escape_string($name2[1]) ."%' "; } else { > foreach($name2 as $namePart) { $sql .= "AND > restaurants.name LIKE '%". mysql_real_escape_string($namePart) ."%' "; > } } } if ($searchAddress) { $sql .= "AND > restaurants.address LIKE '%". mysql_real_escape_string($address) ."%' "; > } $sql .= "ORDER BY restaurants.name;"; > $result = mysql_query($sql); > I'm not sure about MySQL, but in Informix my queries will crash when trying to just append the ORDER BY clause by itself. $sql .= "ORDER BY restaurants.name;"; Also, you have a semi colon before and after the ending quote. TRY $sql .= "AND 1 = 1 ORDER BY restaurants.name";