I read this tutorial about PDO. I had an error and tried the errorInfo() function. However, I get this error when trying to use errorInfo():
Fatal error: Call to a member function errorInfo() on a non-object in C:\Users\Nico\Dropbox\PHP\Vagex Clone\Website\pdo\select.php on line 8
I used this code as it's in the tutorial:
$query = $db->query('SELECT * FROM notexistingtable'); //that was the error I had
if (!$query) {
var_dump($query->errorInfo());
}
So - if I have an error like this, how do I correctly use the errorInfo() function?
See https://www.php.net/manual/en/pdo.errorinfo.php: errorInfo is a method of PDO (the instance is here $db) and not of false which is returned by the failing query.
So use $db->errorInfo() for getting the failure info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With