Dev Dev - 18 days ago 5
PHP Question

MySql LIKE not working

LIKE not working when i searched for 'New Delhi' but when i Searched for Noida it works fine. how to use LIKE when String has Space.

$area = $_REQUEST('area');
$sql = "SELECT * from Student_registration WHERE area LIKE %".$area."%";

Answer

You are missing the single quotes to surround your string :

$sql = "SELECT * from Student_registration WHERE area LIKE '%".$area."%'";