Conjurer Posted October 18, 2006 Share Posted October 18, 2006 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 https://forums.phpfreaks.com/topic/24363-need-to-print-contents-of-tablefetch-error/ Share on other sites More sharing options...
Conjurer Posted October 18, 2006 Author Share Posted October 18, 2006 ;D OOPs! Corrected the name of the table and now it works. Link to comment https://forums.phpfreaks.com/topic/24363-need-to-print-contents-of-tablefetch-error/#findComment-110861 Share on other sites More sharing options...
fenway Posted October 19, 2006 Share Posted October 19, 2006 You should always debug with mysql_error() so that you can catch MySQL-related syntax errors easily. Link to comment https://forums.phpfreaks.com/topic/24363-need-to-print-contents-of-tablefetch-error/#findComment-111379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.