I have a custom piece of MySQL that works on every WordPress system I have seen so far, but fails on one customer system.

I didn't write this, so am working out what it means.

The problem is that it fails to connect to the MySQL database, (or it connects, but gets no data).

What diagnostic should I use to chase this down?

global $db_pdo,$wpdb;

                $sql= "Select * from ".$wpdb->prefix."posts where post_type = :post_type";

                $order_status = $db_pdo->prepare($sql);

                $data=array(':post_type' => 'shop_order');


1 Answer 1


Have you looked at the server log files (MySQL and PHP)? It could be several things:

  • A MySQL permission issue on the db and/or table
  • Table is named differently than stated in your code
  • MySQL and/or WordPress are using older versions that don't support certain syntax

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.