Jump to content

Recommended Posts

mySQL version:5.5.24

 

I need help with the column type ENUM. What I want to happen is for this column to get either yes or no values. I think ENUM is used specifically for this but i dont know how to set up the column for this to work. I tried to just select ENUM as the type and leave everything else blank but when I save it gives me the error "This is not a number". I have other columns, but im almost sure the error is coming from the ENUM column. Please help.

Link to comment
https://forums.phpfreaks.com/topic/274260-help-with-enum/
Share on other sites

Well, first of all you should NOT use an ENUM type if the values are Yes/No (i.e. TRUE/FALSE). Use a Boolean (or Tiny INT) type and store a 1 or 0. If you store a string such as "Yes" or "no" then you have to add additional logic to your code to process, such as

if($active=='yes')
{
   //Do something
}

 

instead, if you use 1 or 0 you can use those values directly because they are interpreted as logical TRUE and FALSE

if($active)
{
   //Do something
}

 

But, the reason you are getting the error is probably because you have some text type field (possibly the ENUM) for which you have not supplied a length.

Link to comment
https://forums.phpfreaks.com/topic/274260-help-with-enum/#findComment-1411314
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.