Mystical wpdb query problem. What I’m doing wrong?
-
I can’t understand what I’m doing wrong. The first situation returns NULL. The second returns correct value. Why the first is not working? (Only the first line is different). The user is logged in and I get the correct id with echo.
$user_ID = get_current_user_id(); echo ($user_ID); // 2 $info = $wpdb->get_var( "SELECT info FROM info_table WHERE user_ID = $user_ID" ); var_dump($info); // NULL
$user_ID = 2; echo ($user_ID); // 2 $info = $wpdb->get_var( "SELECT info FROM info_table WHERE user_ID = $user_ID" ); var_dump($info); // string(1) "1"
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Mystical wpdb query problem. What I’m doing wrong?’ is closed to new replies.