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.


Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.