11Tami Posted June 3, 2007 Share Posted June 3, 2007 Hello, why does the length attribute, to set the character length of what is added to a a mysql field, only seem to work on varchar and not text? Please let me know, thanks very much. Quote Link to comment https://forums.phpfreaks.com/topic/54058-my-sql-length-attributes/ Share on other sites More sharing options...
pocobueno1388 Posted June 3, 2007 Share Posted June 3, 2007 I don't think you set a length for the "text" option. By default it has a limit of 65,000 bytes. I'm not positive that it's not possible to set a length, but as far as I know, you can't. Quote Link to comment https://forums.phpfreaks.com/topic/54058-my-sql-length-attributes/#findComment-267227 Share on other sites More sharing options...
11Tami Posted June 3, 2007 Author Share Posted June 3, 2007 I didn't ask this in mysql because I might have a php question related to it. Can anyone tell me if varchar is the only one that the length value works on? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/54058-my-sql-length-attributes/#findComment-267237 Share on other sites More sharing options...
dough boy Posted June 3, 2007 Share Posted June 3, 2007 You cannot set the limit in the database, but you could set a limit via your input (i.e. count characters, etc.). Here is a link to the storage requirements. http://dev.mysql.com/doc/refman/4.1/en/string-type-overview.html Quote Link to comment https://forums.phpfreaks.com/topic/54058-my-sql-length-attributes/#findComment-267239 Share on other sites More sharing options...
11Tami Posted June 3, 2007 Author Share Posted June 3, 2007 Yes I already did it on the form itself for max characters but when people are using pad files it overrides it. Thanks for the link but it doesn't talk about which options will take the length value. The only place to fix it is the database. Just wondering why it doesn't work on text fields and if varchar length values is the only or best way. Hope someone knows. Quote Link to comment https://forums.phpfreaks.com/topic/54058-my-sql-length-attributes/#findComment-267242 Share on other sites More sharing options...
dough boy Posted June 3, 2007 Share Posted June 3, 2007 VARCHAR and CHAR fields are the only ones that you can use to set a limit because most people that want to limit only want to limit small amounts. if you want to limit a lot, then you have to do it the other way. According to the link you could try setting a VARCHAR(500) and it would be treated as a TEXT field, but maybe it would still have the limit in effect? Quote Link to comment https://forums.phpfreaks.com/topic/54058-my-sql-length-attributes/#findComment-267246 Share on other sites More sharing options...
11Tami Posted June 3, 2007 Author Share Posted June 3, 2007 Thanks a lot. OK I'll try varchar then. I am guessing varchar means various charactors, which means its ok if I use it for text. Quote Link to comment https://forums.phpfreaks.com/topic/54058-my-sql-length-attributes/#findComment-267249 Share on other sites More sharing options...
pocobueno1388 Posted June 3, 2007 Share Posted June 3, 2007 Yes, you can use varchar for text. Quote Link to comment https://forums.phpfreaks.com/topic/54058-my-sql-length-attributes/#findComment-267251 Share on other sites More sharing options...
dough boy Posted June 3, 2007 Share Posted June 3, 2007 Sort of. The main difference between it and CHAR is that if you have VARCHAR(10) and you store 5 characters in it, then it only takes up that much space. However if you store the same 5 characters in a CHAR(10) it will take up 10 spaces. That is the "advantage" of the VAR = Variable as the data being stored could vary. Quote Link to comment https://forums.phpfreaks.com/topic/54058-my-sql-length-attributes/#findComment-267253 Share on other sites More sharing options...
11Tami Posted June 3, 2007 Author Share Posted June 3, 2007 I'm afraid you lost me, I even read it at mysql and didn't understand it there either. So If I have 5 characters in "varchar" like this: 12 as d what will happen compared to those same exact characters in "char"? Quote Link to comment https://forums.phpfreaks.com/topic/54058-my-sql-length-attributes/#findComment-267305 Share on other sites More sharing options...
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.