Unable to get value from database on wordpress

Hey guys so I am trying to grab a value from my database but for some reason its not turning out the way it should be. I am calling everything through wordpress $wpdb.

CODE:

Read More
/***GET USERNAME***/
            global $current_user, $wpdb;
            get_currentuserinfo();
            $accusername = $current_user->user_login ;
            /******SEE IF FIRST TIME DISCOUNT CODE BEEN USED*******/
            $checkFTDiscount = $wpdb->get_var( $wpdb->prepare( 
                "
                    SELECT firsttime_discount 
                    FROM $wpdb->users 
                    WHERE user-login = %d
                ", 
                $accusername
            ) );
            echo $checkFTDiscount;

So technically I should get the value 1 from this because in the data field its drawing from – which is an int(2) – is set to 1 for this user.

Let me know if you need any other info.

Thanks for the help!

EDITED

Once value is gotten it sets these –

if ($checkFTDiscount == 1){
                $validFTDiscount = 1;

            }
            else if ($checkFTDiscount == 0){
                $validFTDiscount = 0;

            }

This does not happen though.

Related posts

Leave a Reply

1 comment

  1. In your example

    WHERE user-login = %d // %d for integers
    

    should be

    WHERE user_login = %s // %s for string and it's a string value and _ instead of -