Just wondering what I’m doing wrong with this code, I’m sure it’s the mysqli_fetch_row line but I’m lost. if I change the $id variable in the $sql query to an actual user id, the query works… so obviously my first query isn’t handling the result correctly… tips anyone? $username is declared earlier
$id = mysqli_query($link, "SELECT id FROM users WHERE username = '$username'");
$id = mysqli_fetch_row($id);
if (!$id)
{
$error = 'Error!';
include 'error.php';
exit();
}
else
$sql = mysqli_query($link, "SELECT moviename FROM movies INNER JOIN usermovies ON movie_id = usermovies.movieid WHERE usermovie.userid = '$id'");
if (!$sql)
{
$error = 'Error!';
include 'error.php';
exit();
}
while ($row = mysqli_fetch_array($sql))
{
$movies[] = array('movie_name' => $row['movie_name']);
}
?>