Jump to content


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


Need to print contents of table...fetch error?

Recommended Posts

I am just looking for a simple way to test if my database is working. Wanted to get a listing of the contents of the user table from my bookmarks database but the code I am using generates the following errror message.
[quote]Fatal error: Call to a member function fetch_assoc() on a non-object in /home/consult/public_html/development/Testing/26/dbtest2.php5 on line 14[/quote]

The code running in php5 is as follows:
$mysqli = new mysqli('localhost',"consult_test", "password");

$result = $mysqli->query("SELECT * FROM users");

while($row = $result->fetch_assoc()) {
print $row['username'] . ' ' . $row['passwd'].' ' . $row['email']. '<br/>';


Are you guys sure this php stuff works!  j/k - just wish I knew what I was doing wrong. At least I got the parsing errors sorted!

Share this post

Link to post
Share on other sites
You should always debug with mysql_error() so that you can catch MySQL-related syntax errors easily.

Share this post

Link to post
Share on other sites


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.