• Resolved gerbil_matrix2

    (@gerbil_matrix2)


    Fatal error: Call to a member function on a non-object in […] line 5.
    Line 4 & 5 are:

    global $wpdb;
    $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->wp_b_lookup WHERE P_num LIKE %d OR Item_description LIKE %s OR category LIKE %s",$searchstring, $searchstring, $searchstring));

    The user enters an alphanumeric value into one form field that posts to this script. I’ve looked at the docs and a few blog examples, but can’t seem to find my mistake. Any help would be very much appreciated.

Viewing 1 replies (of 1 total)
  • Thread Starter gerbil_matrix2

    (@gerbil_matrix2)

    I was able to make the errors go away by making adding some include_once statements in my code as per this link.

    include_once(‘wp-config.php’);
    include_once(‘wp-load.php’);
    include_once(‘wp-includes/wp-db.php’);

    Did the trick.

Viewing 1 replies (of 1 total)
  • The topic ‘Error trying to use wpdb class’ is closed to new replies.