WPDB always returning array(0)?

The below query is always returning an empty array i have checked that the $_POST is working but i am unsure what is going on?

$database = new wpdb(QLBBackendUser, QLBBackendPass, QLBBackendDB, DB_HOST);  

if (isset($_POST['register-user'])):
    $user = $database->get_results('SELECT * FROM users WHERE email='.$_POST["user_email"]);
    var_dump($user);
endif;

Please note this is for WordPress using WPDB Class.

Related posts

1 comment

  1. You should never call the wpdb class directly…If you must, use the global $wpdb object instead. In addition, make sure the user_email has been POSTed (I’m not sure why you’re checking for register-user being set and not user_email). Also, it’s highly unlikely that the table you should be querying is called users (without a prefix). It’s likely wp_users if you’re using the default prefix.

    Finally, there is a handy function that already does what you’re trying to re-implement, called get_user_by:

    $user = get_user_by( 'email', $_POST['user_email'] );
    

    I recommend using the above, instead of trying to re-invent the wheel.

Comments are closed.