vendlus Posted September 30, 2003 Posted September 30, 2003 I'm wondering if anyone can give me an idea of how mySQL handles text fields. I've got a field that could be 30 characters or 250, or anything inbewteen (or possibly more, but unlikely). With space and speed as the main considerations, is it better to use 'text' as the type or like 'varchar(250)'?? I need to dynamically create pages from this table, but not search off of this field or anything. Any queries run on this table will be select queries based on an id field, so I don't think speed will be a big deal either way. My main thing is whether I should just use 'text', since to use 'varchar' I have to use the max number of characters for the field, even though most of the entries won't be that large. Quote
surefire Posted September 30, 2003 Posted September 30, 2003 http://forums.devshed.com/archive/4/2002/04/4/34559 Make sure that you know basic security feature for your database, especially if you are going to be accepting user input from visitors. Become familiar with addslashes and htmlspecialchars functions. Ugly things can happen if you build a database driven site without precautions and safety measures built in. Quote
Sarah Posted September 30, 2003 Posted September 30, 2003 I would check out the mySQL web site documentation: http://www.mysql.com/doc/en/Column_types.html here they give you an explanation of all the types you could use for your field, and you can decide the best for yours. I do know that varchar only goes up to 255 characters. Quote
vendlus Posted October 1, 2003 Author Posted October 1, 2003 Thanks. I did know that varchar only goes to 255 if I had been thinking. Didn't remember that it only uses space as it's needed though (from the link surefire posted). I'm currently using htmlspecialchars in a few places. Almost all of my forms will be in staff sections of the site which check for permission levels before loading the page though, so I'm not as worried about malicious content in this particular form. I certainly will look into some more security measures though once I get the functionality I want working. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.