I am using prepared statements for the first time. And i cannot get the select to work. For some reason, it returns all the records but i cannot get them into variables. I know it returns all the records because if i add echo '1'; to the loop it echo's 1 for each record.
Any assistance would be great. The code is below:
function builditems($quote_id){ if ($stmt = $this->link->prepare("SELECT * FROM `0_quotes_items` WHERE `quote_id` = ?")) { // Bind a variable to the parameter as a string. $stmt->bind_param("i", $quote_id); // Execute the statement. $stmt->execute(); while ($row = $stmt->fetch()) { echo $row['id']; } // Close the prepared statement. $stmt->close(); } } UPDATE: in the error log, i see the following error after adding the while ($row = $stmt->fetch_assoc()) { like suggested:
PHP Fatal error: Call to undefined method mysqli_stmt::fetch_assoc()
I found a link that the same issue was had, but i do not understand how to implement the fix. Any assistance would be great, with regards to a example.