Got stuck with relational database, please guide

Hi Everybody,

Lately i have been working on relational database of two table in php/mysql in INNER JOIN. I want to associate author name and email with theirs quotes in the display for the delete.

but i got some errors message which are:

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given

Warning: Invalid argument supplied for foreach()

Advise and tips will help. THANK YOU

here are my code:
[php]

<?php

if ($_SERVER[“REQUEST_METHOD”]==“POST”) {

$id_select = $_POST[‘id’];

$action = “DELETE FROM user_quotes WHERE id = ‘$id_select’”;

$requet= mysqli_query($db_connection, $action);
}

echo “
”;

$requete = “SELECT joke.id, quoteText, name, email FROM user_quotes INNER JOIN author ON authorID = author.id”;

$resultat = mysqli_query($db_connection, $requete);

while ($rows = mysqli_fetch_assoc($resultat)) {

$quotes []= array(‘id’ =>$rows[‘id’], ‘text’ =>$rows[‘quoteText’], ‘name’=>$rows[‘name’], ‘email’=>$rows[‘email’]);
}
?

Thank you for your participation

<?php foreach ($quotes as $quote):?>

<?php echo htmlspecialchars($quote['text'], ENT_QUOTES, 'UTF-8'); ?> <?php echo htmlspecialchars($quote['name'], ENT_QUOTES, 'UTF-8'); ?> <?php echo htmlspecialchars($quote['email'], ENT_QUOTES, 'UTF-8'); ?>

<?php endforeach; ?> [/php]
  1. Please use the code tags, it is the button that says php when posting.

Your issues lays with not verifying the connection or anything else. You probably aren’t connecting to the database, which is returning false (making it a boolean).

Sponsor our Newsletter | Privacy Policy | Terms of Service