Jump to content

Inserting into table with ENUM value? the right way?


bilis_money

Recommended Posts

hi

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');
[/code]

Your help will be appreciated much.


Thanks in advance.


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.

Archived

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

×
×
  • Create New...

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.