Mysql Question

liunx

Guest
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). <br /><br />With space and speed as the main considerations, is it better to use 'text' as the type or like 'varchar(250)'??<br /><br />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.<!--content-->
<a href="http://forums.devshed.com/archive/4/2002/04/4/34559" target="_blank">http://forums.devshed.com/archive/4/2002/04/4/34559</a><br /><br />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.<br /><br />Ugly things can happen if you build a database driven site without precautions and safety measures built in.<!--content-->
I would check out the mySQL web site documentation:<br /><a href="http://www.mysql.com/doc/en/Column_types.html" target="_blank">http://www.mysql.com/doc/en/Column_types.html</a><br /><br />here they give you an explanation of all the types you could use for your field, and you can decide the best for yours.<br /><br />I do know that varchar only goes up to 255 characters.<!--content-->
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).<br /><br /><br />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. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /><!--content-->
 
Back
Top