rubing Posted April 29, 2008 Share Posted April 29, 2008 I am getting the following error: Fatal error: Call to a member function fetch_assoc() on a non-object in /home/rubing/public_html/bandpage.php on line 14 Yet, I am referencing a mysqli object. Here is my code: $id=$_GET['bandid']; $query="SELECT BandSite FROM Bands WERE Bands.ID=" . $id; $result = $conn->query($query); while (($row = $result->fetch_assoc()) !== NULL) { header("location: {$row['BandSite']}"); } Link to comment https://forums.phpfreaks.com/topic/103484-mysqli-object-showing-up-as-non-object/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 29, 2008 Share Posted April 29, 2008 Edit: nevermind what I previously wrote. What is probably happening is your query is failing so that $result is not a result object. You always need to check for errors before using data. The php manual contains example code on how to do this. Link to comment https://forums.phpfreaks.com/topic/103484-mysqli-object-showing-up-as-non-object/#findComment-529886 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.