PDA

View Full Version : Fatal error: Call to a member function close() on a non-object...



squarehippo
05-04-2010, 12:16 AM
Can someone please explain why I'm getting:

Fatal error: Call to a member function close() on a non-object on line 67

Line 67 is: $result->close();

I can connect to the database but apparently, that's about it. The code was copied over from a development machine where it works. I copied the database over too and have verified everything using phpMyAdmin. I also set up a database user with full privileges and assigned that to the database. Am I missing anything??



$db = new mysqli('localhost', 'myUsername', 'myPassword', 'myDatabase');

$sql = "select * FROM listingTable";
$result = $db->query($sql);

//do stuff

$result->close();
$db->close();

squarehippo
05-05-2010, 07:42 PM
I still don't know what the problem was, but recreating the database from scratch fixed the problem. (Fortunately, it was a very small database.)