Jump to content

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


Conjurer

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:
[code]
<?php
$mysqli = new mysqli('localhost',"consult_test", "password");
$mysqli->select_db("consult_bookmarks");

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

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

$result->close();
?>[/code]

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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.