Jump to content

mysqli object showing up as non-object


rubing

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.