MySQL Like Query Fails In PHP
$result = mysql_query('SELECT * FROM MasjidMaster WHERE MasjidName LIKE ('%moh%')') or die mysql_error(); The error i get is Parse error: syntax error, unexpected T_STRING in
Solution 1:
$result = mysql_query("SELECT * FROM `MasjidMaster` WHERE `MasjidName` LIKE '%moh%'") or die(mysql_error());
A little more tweaking, for good practice wrap table names and table columns in ``.
You also shouldn't need () around ('%moh%')
Solution 2:
Try this-
$result = mysql_query("SELECT * FROM MasjidMaster WHERE MasjidName LIKE ('%moh%')") or die(mysql_error());
You forget parentheses
with die(mysql_error())
Solution 3:
try this:
$result = mysql_query("SELECT * FROM MasjidMaster WHERE MasjidName LIKE '%moh%' ") or die(mysql_error());
use die()
like this die(mysql_error())
.
Post a Comment for "MySQL Like Query Fails In PHP"