The problem is probably quite simple.
$q = "SELECT id FROM users
WHERE name LIKE '%$u%' OR active LIKE '%$u%'";
echo $q;
$u = mysql_query($q) or die("There is a server error : " . mysql_error());
$u = mysql_fetch_array($u);
print_r($u);
But it returns me
[id] => 6
When I execute the query in Mysql Workbench it returns
6
7
8
It’s probably a fetching problem but I don’t understand why.
Thanks 🙂
mysql_fetch_array()only returns one row. To get more rows, you need a loop.Also
mysql_fetch_array()returns both a string association and a integral indexing.What you want to use is
mysql_fetch_assoc()like so: