frijole Posted March 4, 2008 Share Posted March 4, 2008 I would like to store the embed HTML from sites like YouTube for certain videos on my DB, so I can echo it when I want. I have just counted the characters and it was 303. Is that too large? Is there another way I can do this? Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/ Share on other sites More sharing options...
bpops Posted March 4, 2008 Share Posted March 4, 2008 I'm assuming your using VARCHAR. You should try TEXT or BLOB. http://dev.mysql.com/doc/refman/5.0/en/string-types.html Edit: Just reading the link I gave you, The length can be specified as a value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions So depending on your MySQL version, varchar might work for you. Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483331 Share on other sites More sharing options...
frijole Posted March 4, 2008 Author Share Posted March 4, 2008 thanks, I looked at the link and I cannot find a specific number of characters that can be stored. Any Idea where to look for that? Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483334 Share on other sites More sharing options...
phpSensei Posted March 4, 2008 Share Posted March 4, 2008 make it LONGTEXT Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483335 Share on other sites More sharing options...
frijole Posted March 4, 2008 Author Share Posted March 4, 2008 do you know how long that can be? Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483358 Share on other sites More sharing options...
deadonarrival Posted March 4, 2008 Share Posted March 4, 2008 Very I think 2^32 bits which would make it 4billlion possible numbers (usually -2 to +2 billion) More than 303 at any rate. Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483361 Share on other sites More sharing options...
phpSensei Posted March 4, 2008 Share Posted March 4, 2008 Longer than that. Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483367 Share on other sites More sharing options...
frijole Posted March 4, 2008 Author Share Posted March 4, 2008 is that a huge waste of space? Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483372 Share on other sites More sharing options...
jedney Posted March 5, 2008 Share Posted March 5, 2008 Try setting the field as LONGBLOB. Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483406 Share on other sites More sharing options...
frijole Posted March 5, 2008 Author Share Posted March 5, 2008 do you know the attributes of LONGBLOB? I looked that one up in the manual but couldn't understand the summary. Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483409 Share on other sites More sharing options...
jedney Posted March 5, 2008 Share Posted March 5, 2008 I'm unsure of the attributes, I use them for larger inoput fields because it has a maximum length of 4,294,967,295 characters! Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483418 Share on other sites More sharing options...
frijole Posted March 5, 2008 Author Share Posted March 5, 2008 that will do. Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483428 Share on other sites More sharing options...
jedney Posted March 5, 2008 Share Posted March 5, 2008 I'd sure hope so, if you needed more characters than that, I'd recommend multiple fields Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483430 Share on other sites More sharing options...
jedney Posted March 5, 2008 Share Posted March 5, 2008 I'm so sorry, I gave you the wrong information. It's LONGTEXT. Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483442 Share on other sites More sharing options...
phpSensei Posted March 5, 2008 Share Posted March 5, 2008 use LONGTEXT, more space the better. You can limit the amount of data you put in it. edit: HAHA, who said waste of space... Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483446 Share on other sites More sharing options...
me1000 Posted March 5, 2008 Share Posted March 5, 2008 QUESTION if I may: Why store the embed code? why not just the URL which can then be used in the embed code generated by PHP. This will make it more flexible in the future, take less space on the server, etc... Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483451 Share on other sites More sharing options...
maxudaskin Posted March 5, 2008 Share Posted March 5, 2008 I can see someone needing that if they are doing websites that are stored in databases instead of HTML files... waste of space? I don't know, I think it takes less space to put a full HTML file coded in a database rather than a seperate HTML file. Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483529 Share on other sites More sharing options...
frijole Posted March 5, 2008 Author Share Posted March 5, 2008 so worrying about wother or not it is a waste of space is not necessary? Or it is? Sarcasm related to coding is over my head. Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483591 Share on other sites More sharing options...
unsider Posted March 5, 2008 Share Posted March 5, 2008 Try setting the field as LONGBLOB. If you've got images you want to store, longblob is certainly your friend. And I'm curious if wasting space is an issue as well. Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-483606 Share on other sites More sharing options...
deadonarrival Posted March 6, 2008 Share Posted March 6, 2008 Would be a waste of space if using a flat file system which takes x chars as being a field and pads out the rest, but mysql is a bit smarter then that Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-485523 Share on other sites More sharing options...
frijole Posted March 6, 2008 Author Share Posted March 6, 2008 QUESTION if I may: Why store the embed code? why not just the URL which can then be used in the embed code generated by PHP. This will make it more flexible in the future, take less space on the server, etc... that could work. although I would have to make a different script for each server, i.e. YouTube, Google Video etc. right? Quote Link to comment https://forums.phpfreaks.com/topic/94378-how-to-store-text-larger-than-255-characters/#findComment-485530 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.