PHP-MySQL-Class icon indicating copy to clipboard operation
PHP-MySQL-Class copied to clipboard

Return error

Open Lintzman opened this issue 10 years ago • 5 comments

Started using your class and it works great except when I had a typo in my SQL and was wondering why nothing was being inserted into my DB. A great addition to the script would be to display an error if a query fails. Keep up the good work.

Lintzman avatar Jun 11 '15 05:06 Lintzman

You should be able to use the $lastError variable to return this..

$db = new MySQL('.....'); /query stuff...mmmkay/ echo $db->lastError;

Hope it helps.

thejwalker avatar Jun 24 '15 21:06 thejwalker

I'm using the PDO class which doesn't have a lastError variable.

Lintzman avatar Jul 06 '15 02:07 Lintzman

Hi. I know I'm late to the game here, and you're probably better off using a different framework, but if you want to see the error, you can add echo "\nPDOStatement::errorInfo():\n"; $arr = $stmt->errorInfo(); print_r($arr); after line 57 in class.DBPDO.php

You'll likely need to comment those lines out or put in a DEBUG = TRUE statement to flip that info on and off... there's probably a better way to do it... but yeah, thats all I got right now.

mrbobdobolina avatar Jun 29 '20 18:06 mrbobdobolina

has anyone got a solution for this ? how to see the errors ?

mrbeandev avatar Sep 17 '21 10:09 mrbeandev

i got it ! , check my DBPDO.php file > https://github.com/mrbeandev/PHP-MySQL-Class 😄

mrbeandev avatar Sep 17 '21 11:09 mrbeandev