Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\htdocs\clphp03\new_post09.php on line 112 Line 112 $result = $db->query($sql) or die(mysqli_error()); $db = dbConnect('query'); $sql = 'SELECT * FROM mammals WHERE postid = $postid'; $result = $db->query($sql) or die(mysqli_error()); while ($row = $result->fetch_assoc()) { echo $row['postid']; } PHP:
i think it is this part of your code $sql = 'SELECT * FROM mammals WHERE postid = $postid'; it should possibly be $sql = "SELECT * FROM mammals WHERE postid = '$postid'";
Thanks for the help. I did what you suggested, but I get the same error message. Perhaps your suggestion corrected part of the problem.
I removed or die(mysqli_error()) and I get a new error message. Fatal error: Call to a member function fetch_assoc() on a non-object in C:\htdocs\clphp03\new_post09.php on line 113
Thanks for the help. When I add new I get a different error message. Fatal error: Class 'dbConnect' not found in C:\htdocs\clphp03\new_post09.php on line 110
well, the answer is in your post itself. Click on mysqli_error in your code. The function accepts a "resource link" argument.. that is giving you the error... $result = $db->query($sql) or die( mysqli_error( $result ) ); PHP: alternately, if your $db is a mysqli object ( or inherits mysqli ), you can use $result = $db->query($sql) or die( $db->error ); PHP: hopefully this solves...
Thank you all for your help. bvraghav was right on. I tried or die( mysqli_error( $result ) ); and got nothing. Then I tried or die( $db->error ); and received an error message telling me there was no such table with that name. I forgot to update the name of the table in that last piece of code.