Jump to content


This topic is now archived and is closed to further replies.


Inserting into table with ENUM value? the right way?

Recommended Posts


i'm now trying to insert the datas into a table
with field 'activated' and was set as ENUM.
remember that 'activated' column field is ENUM.

is this correct?
[code]$query = "INSERT INTO users (first_name, last_name, username, password, email_address, signup_date, activated)
VALUES ('$fname', '$lname', '$user', '$password', '$email', '1')";

mysql_query($query) or die('Error, insert query failed');

Your help will be appreciated much.

Thanks in advance.

Share this post

Link to post
Share on other sites
Yes that is fine. ENUM only accepts the values you provided when you created the table. So if you did this when creating the users table:
[code]CREATE TABLE users (
-- rest of fields here --
activated ENUM('0','1') DEFAULT '0'
-- rest of query here --)[/code]
Then the activated field will only accept 0 or 1 as the value. if the value given was not 0 or 1 it'll use the default value which was 0.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.