Avatar of Wanda Marston
Wanda Marston
Flag for Canada

asked on 

What is the proper code to pass to the database to retrieve the proper information?

I receive this error message when trying to retrieve information from a database with a prepared statement - We have no data for this ID     

I know that there is information in the database. I am new to prepared statements. 

Following is my code:<?php
$id = isset($_GET['id']) ? $_GET['id'] : false; if ($id) {  } $query = <<< QUERY SELECT notices.upload_id,  notices.description, notices.amount, notices.currency,  notices.location,  users.email FROM notices INNER JOIN users ON notices.users_id = users.id WHERE notices.users_id= ? QUERY; if (! $stmt = mysqli_prepare($db, $query)) { die("There was a problem preparing the statement"); } mysqli_stmt_bind_param($stmt, "d", $id); mysqli_stmt_bind_result($stmt, $upload_id, $description, $amount, $currency, $location,  $email); mysqli_stmt_execute($stmt); if (mysqli_stmt_fetch($stmt)) {                               $html = <<< EOT     <form action="ContactPoster.php" method="post">         <p>Description: {$description}</p>         <p>Amount: {$amount}</p>         <p>Currency: {$currency}</p>         <p>Location: {$location}</p>                 <input type="hidden" name="toemail" value="{$email}"> EOT;       echo $html; } else {     echo "We have no data for this ID"; } ?>

Open in new window


DatabasesPHP

Avatar of undefined
Last Comment
Chris Stanyon

8/22/2022 - Mon