WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

PHP Notice: Object of class WP_Error could not be converted to int in /var/www/vhosts/hayhauler.co/httpdocs/wp-includes/functions.php on line 2568, referer: http://hayhauler.co/

I'm not even sure where to start with this or the right question to ask. I know that it is preventing me from posting some information into a database using this:

    INSERT INTO $wpdb->quotes
    VALUES (%d,%s,%s,%d,%s,%s)

And this error follows it:

mysql_real_escape_string() expects parameter 1 to be string, object given in /var/www/vhosts/hayhauler.co/httpdocs/wp-includes/wp-db.php on line 789, referer: http://hayhauler.co/

Any help or direction would be greatly appreciated.

share|improve this question
up vote 0 down vote accepted

One of the variables you're trying to pass into wpdb::prepare is a WP_Error object. WP_Error's are like exceptions mixed with return codes: some functions in the WordPress API return WP_Error objects to tell you something went wrong (like get_terms).

We'll need to see more of your code to be more specific, but you can test for them with the function is_wp_error. So, let's say $brokerID was causing the issue:

$brokerID = some_function_that_gets_broker_id();

    // do stuff to fix it
    // Your original code goes here.
share|improve this answer
Wow. This form of error checking is a whole new word for me. Thanks. It helped point me in the right direction. Basically, $estimatedship didn't have a corresponding column in the table. I'm just not sure why WP didn't throw a more specific error into the window since I had define('WP_DEBUG', true); – Greg Wiley Sep 25 '12 at 3:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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