SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    85
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Boolean value automatically changing in database

    Hello,

    All of a sudden my boolean value changes in the database and I'm not exactly sure what's going on. I've tried searching for this but the only thing that comes up is using auto-increment feature and that's not what I want to happen.

    Here's a break down:

    PHP Code:

    $id 
    strip_tags($_GET['id']);
    $act strip_tags($_GET['activation']);

    if (
    $id && $act)
    {
        
    $query mysqli_query($connect"SELECT * FROM useraccounts WHERE userID = '$id' AND verification_code = '$act'");
        
    $checkrow mysqli_num_rows($query);

        if (
    $checkrow == 1)
        {
            
    // run query
            
    $set_activation mysqli_query($connect"UPDATE useraccounts SET activated = '1' AND userID = '$id'") or die(mysqli_error($connect));
            echo 
    "Your account has been verified. Please log in!";    
        }
        else
            die(
    "Incomplete verification code. Please copy and paste if link is broken.");
    }
    else
        die(
    "Invalid verification data. Please submit support ticket or click the resend email link for a fresh validation code."); 
    The above code is a snippet from an email verification system I'm building and though everything works as it should, script side, anytime I test the verification process and I verify the email all other emails in the database switch back to zeros as though they were never verified and I know they were.

    I'm using boolean value with - as defined: 0 for default (not selecting "as defined" doesn't set the 0 as default) for a category labled "activated" which grants them access if the row contains 1 and no access if it contains 0.

    I'm not sure what's going on and was hoping one of you SQL gurus could point me in the right direction.

    Additional Info:
    The activated category is not set to unique - atleast it wasn't when I added it.

    Thanks in advance

  2. #2
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    your line

    PHP Code:
            $set_activation mysqli_query($connect"UPDATE useraccounts SET activated = '1' AND userID = '$id'") or die(mysqli_error($connect)); 
    should be

    PHP Code:
            $set_activation mysqli_query($connect"UPDATE useraccounts SET activated = '1' WHERE userID = '$id'") or die(mysqli_error($connect)); 
    as you only want to set 'activated' to 1 for the UserID that is currently being dealt with.
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2007
    Posts
    85
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi Mandes,

    Thanks a million! I was starting to pull my hair out in batches. I don't even remember changing the term WHERE to AND. It's going to be a long day I guess lol.

    Again, thanks for the extra pair of eyes.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •