Jump to content

Recommended Posts

I am making a form for user to input new account information and am unsure which types to use for the best results.

 

For a telephone number is it best to use a VARCHAR ?

 

What about a block of text? BLOB?

 

Radio buttons which serve as YES/NO  ???

 

Any pointers would be appreciated :)

Link to comment
https://forums.phpfreaks.com/topic/98331-which-types/
Share on other sites

Text: *TEXT (there are a couple different variations of the TEXT type)

 

Sorry I should be asking all the questions at once instead of just as they come.

 

but what do you mean there are a couple of variations of text ? and which one should I be using ?  is "*TEXT" an actual type?

 

**EDIT** IGNORE - I see them now TEXT/MEDIUMTEXT/LONGTEXT  I have chose long text.

Link to comment
https://forums.phpfreaks.com/topic/98331-which-types/#findComment-503195
Share on other sites

I should probably point out however that if you want a BIT to come out as an numeric representation you'll need to do the following:

SELECT `bitfield`+0 FROM ...

 

You need to +0 to the field that contains the bit to get the numeric representation out of it.

 

note: this is as of 5.0.3

Link to comment
https://forums.phpfreaks.com/topic/98331-which-types/#findComment-503217
Share on other sites

Thanks guys!

 

 

One last question, when inputting a monetry amount would you use the type of "DECIMAL" ?

I use DOUBLE.

DOUBLE is terrible for monetary values -- floating-point error hell.

 

Check the mysql documentation for the size limitations of the different TEXT types. I have never needed anything more than TEXT. Also, regarding a yes|no option, you can always use BIT(1) ;)

In v5+, VARCHAR can be up to 65K -- much, much better than TEXT for about 15 different reasons.

 

And as for yes/no, I question your db design.

Link to comment
https://forums.phpfreaks.com/topic/98331-which-types/#findComment-503625
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.