I'm using MySQL version 5.0.51a and PHP to access the database, and this query returns nothing when it should return at least 2 rows which match the LIKE condition.
$result = mysql_query("SELECT * FROM user WHERE name LIKE '%".$search."%'OR email LIKE '%".$search."%' ORDER BY ".$order, $con);
The $search variable is 'Name',
there is no problem with ORDER, $order or $con, i've already tried that, and there are 2 rows where the name is 'Name', but somehow it can't find those rows and it returns nothing.
Does anybody know where the problem is?
解决方案
Try removing double commas
$result = mysql_query("
SELECT
*
FROM user
WHERE name LIKE '%{$search}%' OR email LIKE '%{$search}%'
ORDER BY ".$order, $con);