I have the following code that has two queries. The first gets an ID that is going to be used on the next query. I this error on the second query:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\b\pprincipal.php on line 132
Here is the first query (For the ID of the user that has data present in that table)
$query2 = mysql_query("SELECT DISTINCT competencias, id_user FROM ce");
$ut = array();
while ($result = mysql_fetch_array($query2)) $ut[] = $result;
foreach ($ut as $u){
$id_user=$u[1];
echo "<li class='has-sub'><a>" .$u[0]. "</a>";
}
And here is the Query that is giving me the error:
$query3 = mysql_query("SELECT id, nome FROM utilizadores WHERE id=$id_user");
$utt = array();
while ($result2 = mysql_fetch_array($query3, $con)) $utt[] = $result2;
foreach ($utt as $u2){
echo "<ul><li><a>". $u2[0]. "</a></li>";
}
This second query is done right, because i have echoed the array and it was okay. But it gives me the error on the WHILE loop.