How to check if an inserted value exist in my database table
-
Hi there,
In my registration page I put a radio button to check the user_role and a text box to insert a user reference(I already have a table of references in my database type of variable varchar)
I added some code to verify that the inserted value exist in my table:
$reference_info = $_POST['reference_info']; $role_info = $_POST['role_info']; // Get All references from database global $wpdb; $q = "select reference from ".$wpdb->prefix."university_attributes WHERE reference ='". $reference_info. "'"; $r = $wpdb->get_results($q); if (($role_info=='Seller') && (!in_array($reference_info,$r))){ $errors->add('reference_info', __('<strong>ERROR</strong>: Your reference information is invalid.')); }
But even when I put the same value stored in my table I get the error message:
Your reference information is invalid
Any help will be appreciated and thanks in advance!
- The topic ‘How to check if an inserted value exist in my database table’ is closed to new replies.