PHP variable in SQL select issues
-
Probably a general coding issue and not specific to the plugin.
I have the following snippet, but for some reason user_id = $current_user_id is ot working. If I use a known ID for user_id it works correctly.
I’m still very green, can anyone kindly point out what I’m doing wrong?function fetch_member_id(){ $current_user = wp_get_current_user(); $current_user_id = $current_user->ID; global $wpdb; $result = $wpdb->get_results('SELECT meta_value FROM usermeta WHERE meta_key = \'random_number\' AND user_id = $current_user_id'); foreach($result as $row){ return 'Membership ID: '. $row->meta_value; } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘PHP variable in SQL select issues’ is closed to new replies.