Jump to content


Inserting into table with ENUM value? the right way?

  • Please log in to reply
2 replies to this topic

#1 bilis_money

  • Members
  • PipPipPip
  • Advanced Member
  • 621 posts

Posted 07 August 2006 - 12:56 PM


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

#2 Daniel0

  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 07 August 2006 - 01:24 PM

Yeah that should work.

#3 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 07 August 2006 - 02:29 PM

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:
-- rest of fields here --
activated ENUM('0','1') DEFAULT '0'
-- rest of query here --)
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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users