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.


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.
  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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