MySQL Forums
Forum List  »  PHP

Re: Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc()
Posted by: Sean Van Zant
Date: November 25, 2018 01:58PM

Thank you for responding so quickly. Thank you also for being willing to and for helping me.

I changed some of the code that I originally included in when posting this. I also need to find out how to properly code the href included in the code following to echo out the id of each row.

Here's the error message that I am getting currently after all of the changes to the previous code: Notice: Undefined variable: row in C:\wamp64\www\seanvzwebguy\A10\customers.php on line 76

I get that I haven't created a $row variable yet. But what other variable should I possibly use? Or how would I use the $row variable in a way that echoes out the rows correctly?

And as you might guess, I'm getting the above error probably 248 more times :)

I am using Wampserver 3.1.1 64bit. PHP version 7.2.10. And I am running Win 10 Pro with the latest updates if that matters.

This is the PHP code I also changed at the beginning of the customers.php file that you might need to use to be able help me better with:


include 'connection.php';

$query = "SELECT id, first_name, last_name FROM customers ORDER BY
last_name asc";
$stmt = $db->prepare($query);
$stmt->bind_result($id, $first_name, $last_name);

// count the number of customers
$total_customers = $stmt->num_rows;


Here's lines 72-83 that I having the most challenges with echoing out correctly within the table:

while($stmt->fetch()) {
echo '<td>'.$row["id"].'</td>;
echo '<td>'.$row["first_name"].'</td>';
echo '<td>'.$row["last_name"].'</td>';

Here's the question about with echoing out the id of each row on line 96:

<td class="text-center"><a class="btn btn-xs btn-primary" href="details.php <?php echo $id ?>">Details</a></td>

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.