j.silver Posted November 22, 2016 Share Posted November 22, 2016 Hi all, <?php require 'db/connect.php'; $result = $db->query("SELECT * FROM people"); ?> I obtained a blank page running the above script, which indicates that everything is fine (path and table name are correct). I then removed the * from the query to see if it would report an error, but it did not. I added print_r($result); and run it. Nothing has changed. I included the * and run, it reported the number of rows and columns in the table. Why there has a been a lack of error reporting in this instance, noting that the ini file is configured to report all sorts of errors, even the warnings and notices (and it is reporting all that in other scripts)? Link to comment Share on other sites More sharing options...
Ingolme Posted November 22, 2016 Share Posted November 22, 2016 What type of object is $db? PDO won't throw errors unless you specifically tell it to. $db->query() will just return false if the query is wrong. If you're using PDO, be sure to set the error mode http://php.net/manual/en/pdo.setattribute.php $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); Link to comment Share on other sites More sharing options...
j.silver Posted November 22, 2016 Author Share Posted November 22, 2016 $db is no more than a simple mesqli connection: $db = new mysqli('127.0.0.1', 'root', '', 'user'); Link to comment Share on other sites More sharing options...
Ingolme Posted November 22, 2016 Share Posted November 22, 2016 I believe mysqli does not throw errors either, you have to test that the query returns false. You can also set error reporting with $mysqli_driver->report_mode Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now