• Hi every one, hope you are doing well. Was getting the dreadful Missing argument 2 for wpdb::prepare() error on a site, from an old custom plugin that was written.

    I went into the code of the plugin and changed this
    $tablequery = $wpdb->get_row( $wpdb->prepare("SELECT * FROM wp_poker_table_room WHERE id = ".$id) );

    To This
    $tablequery = $wpdb->get_row( $wpdb->prepare("SELECT * FROM wp_poker_table_room WHERE id = %d", $id ) );

    The error went away, but I am not sure if my code is 100% correct

    There is also an error in the admin, same kind of error
    the code is this
    $tablequery = $wpdb->get_row($wpdb->prepare("SELECT * FROM wp_poker_table_room WHERE id = " . $tableid));

    but I am not sure how to fix that one.
    Any suggestions would be peachy!

    Thank you kindly

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

    (@teclive)

    I believe I found the solution to the second error
    $tablequery = $wpdb->get_row($wpdb->prepare("SELECT * FROM wp_poker_table_room WHERE id = %d", $tableid));

Viewing 1 replies (of 1 total)
  • The topic ‘Missing argument 2 for wpdb::prepare()’ is closed to new replies.