I'm trying to display the first and last name of the user based on the user_id. But I keep getting the error"Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean" using this code here:
<?php
require 'php/connection.php';
$sql = "SELECT * FROM gift_user WHERE user_id = 1";
$result = mysqli_query($conn, $sql)
while ($row = mysqli_fetch_assoc($result)) {
echo"<h2>".$row['first_name']." ".$row['last_name']."'s List</h2>";
}
?>
But when I use the same code trying to select from another table it retrieves the data fine. As shown here:
<?php
require 'php/connection.php';
$sql = "SELECT * FROM user_lists WHERE user_id = 1";
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($result)) {
echo"<tr>";
echo"<td>".$row['g_name']."</td>";
echo"<td>".$row['g_price']."</td>";
echo"<td><a href=".$row['g_store'].">Go to Site</a></td>";
echo"<td>".$row['g_notes']."</td>";
echo"</tr>";
}
?>
The only difference between the tables is that the user_id is the primary key in the gift_user table but not in the user_lists table.