On Tue, Jul 21, 2009 at 12:26 PM, Miller, Terion<tmiller@xxxxxxxxxxxxxxxxxxxx> wrote: > Why isn't this working for searching? Check your concatenation in the query. You need some white space padding your SQL segments, otherwise the text all starts to run together. (I had to reformat it. For some reason, most of the code snippets you post end up all run together on a single line, at least in Gmail.) <?php // 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) { // ADDED SPACE HERE $sql .= " AND restaurants.name LIKE '%". mysql_real_escape_string($name) ."%' "; if(count($name2) == 1) { // ADDED SPACE HERE $sql .= " AND restaurants.name LIKE '%". mysql_real_escape_string($name2[1]) ."%' "; } else { foreach($name2 as $namePart) { // ADDED SPACE HERE $sql .= " AND restaurants.name LIKE '%". mysql_real_escape_string($namePart) ."%' "; } } } if ($searchAddress) { // ADDED SPACE HERE $sql .= " AND restaurants.address LIKE '%". mysql_real_escape_string($address) ."%' "; } // ADDED SPACE HERE $sql .= " ORDER BY restaurants.name;"; $result = mysql_query($sql); Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php