Updating values in MySQL table

Hi,

I was wondering how I would change an ENUM value from the default 0, to the other value of 1. I wanted it so once the email is verified the account is activated my changing the value “ver” from 0 to 1. This is what I have to far, what am I doing wrong.

[php]$update = mysql_query(“UPDATE accounts SET ver=1 WHERE usr=’$usr’ AND ema=’$ema’”);

if ($update)
{

echo "$usr
";
echo "$ema
";
echo “Verified!”;

}[/php]

At the moment it displays the username, email and “Verified!”, but when I go and check the database the value is still at 0. Is it something to do with it being an ENUM?

Thanks!

It could be what are the values for the ENUM ?
Because these are static and cannto be random they are already set so could be anything so look in the structure and the ver see what it has or copy and paste that line from phpmyadmin or what ever program you use.

Thanks for your response,

They can be set to either ‘0’ or ‘1’

Thanks

I have just put ‘’ around the 1 and it seems to work! Huh?
Could someone explain that to me?

Thanks,
Ri1es

Its not php so needs to be contained or whitespace or other char might get aded to the mysql

Also, it really depends on how the database is set up. If you define the field as ENUM, then it is really a text field.
Enum’s are not numbers. Therefore, when you update it, use the quotes. Enum is set up so that you can use any item in the list. Such as “Male”, “Female”, “Other”, or “Unverified-Email”, “Verified-Email”, or “0”, “1”. It is very useful as you can use a set option like Male/Female and display the results without having to convert “0” to “Male”, etc…

But, it is not a numeric field. That would be BOOLEAN for 0/1 or another format.

Hope that helps explain it further…

Sponsor our Newsletter | Privacy Policy | Terms of Service