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:



$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

your line


        $set_activation = mysqli_query($connect, "UPDATE useraccounts SET activated = '1' AND userID = '$id'") or die(mysqli_error($connect)); 

should be


        $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.

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.