WP_Error message

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:

<?php
$brokerID = some_function_that_gets_broker_id();

if(is_wp_error($brokerID))
{
    // do stuff to fix it
}
else
{
    // Your original code goes here.
}