SQLSTATE[HY000]: General error: 2053

| mysql | pdo | PHP

I encountered the following odd exception:

PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2053 ' in /home/bramp/my.php:29
Stack trace:
#0 /home/bramp/my.php(29): PDOStatement->fetch(2)

Searching on Google didn’t reveal much help, but I eventually figure out the root cause. Spot the mistake:

...
$sql = 'SELECT TRIGGER_NAME, TRIGGER_GROUP, JOB_NAME FROM QRTZ_TRIGGERS';
$sth = $dbh->prepare($sql) or die('Failed to prepare SELECT TRIGGER query');
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
...

I am missing a

$sth->execute();

in between the prepare and the fetch. Easy fix. For reference I’m using a old version of PHP 5.1.6, and MySQL client 5.0.45.

comments powered by Disqus