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%'") ordie(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%')") ordie(mysql_error());
You forget parentheses
with die(mysql_error())
Solution 3:
try this:
$result = mysql_query("SELECT * FROM MasjidMaster WHERE MasjidName LIKE '%moh%' ") ordie(mysql_error());
use die()
like this die(mysql_error())
.
Post a Comment for "Mysql Like Query Fails In Php"