Jump to content

Lack of Error Reporting


j.silver
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...