trying to select from a double select but it doesnt work. I get Warning: mysqli_query(): Couldn’t fetch mysqli. this is the code:
[code=php]
<?php
$result = mysqli_query($con, “SELECT u.* FROM users AS u JOIN (SELECT visitorid FROM visitors AS v WHERE v.userid = $userid ORDER BY last_visit DESC LIMIT 6) AS v1 ON u.user_id = v1.visitorid”);
?>
<table style=”width:100%”>
<?php
while($row = mysqli_fetch_array($result))
{
$cuser = $_SESSION[‘user’];
$favorite = $row[‘username’];
echo “username: $favorite”; //works
$res2 = mysqli_query($con, “SELECT * FROM favorites WHERE favorite=’$favorite’ AND cuser=’$cuser'”); //Warning: mysqli_query(): Couldn’t fetch mysqli
$row2 = mysqli_fetch_array($res2);
$favorite = $row2[‘favorite’];
echo “Favorite= $favorite”;
?>
…..
…..
…..
</table>