141n Posted March 27, 2008 Share Posted March 27, 2008 Hey guys, just a quick question. I'm setting up a site thats going to contain a blog section of sorts. It's the first time I've attempted this and was wondering, when setting up the MySQL Database which field type to use to store the main content as. I.e, VARCHAR, LONGTEXT, LONGBLOB? I'd appreciate the reply or even a clarifcation of the difference and which is best suited ^^ Many Thanks, Iain Quote Link to comment https://forums.phpfreaks.com/topic/98227-to-blob-or-varchar/ Share on other sites More sharing options...
wildteen88 Posted March 27, 2008 Share Posted March 27, 2008 VARCHAR has a max character length of 255 characters. SO obviously this will not suite your needs. When storing large quantities of text within a database use TEXT or LONGTEXT Quote Link to comment https://forums.phpfreaks.com/topic/98227-to-blob-or-varchar/#findComment-502613 Share on other sites More sharing options...
cooldude832 Posted March 27, 2008 Share Posted March 27, 2008 VARCHAR has a max character length of 255 characters. SO obviously this will not suite your needs. When storing large quantities of text within a database use TEXT or LONGTEXT keyword being text if it will have styling blob is better Quote Link to comment https://forums.phpfreaks.com/topic/98227-to-blob-or-varchar/#findComment-502652 Share on other sites More sharing options...
aschk Posted March 28, 2008 Share Posted March 28, 2008 BLOB is a binary large object and generally speaking is used to store binary data (images/exes/other large binary objects), whereas in most cases you'll be looking to use TEXT as it's suited better to textual input (which is what a blog will most likely be). Quote Link to comment https://forums.phpfreaks.com/topic/98227-to-blob-or-varchar/#findComment-502937 Share on other sites More sharing options...
fenway Posted March 28, 2008 Share Posted March 28, 2008 VARCHAR has a max character length of 255 characters. SO obviously this will not suite your needs. When storing large quantities of text within a database use TEXT or LONGTEXT VARCHAR is now up to 65K in v5 -- almost no need to ever use TEXT, which is *very* evil. Quote Link to comment https://forums.phpfreaks.com/topic/98227-to-blob-or-varchar/#findComment-503607 Share on other sites More sharing options...
141n Posted March 29, 2008 Author Share Posted March 29, 2008 ^^ Thanks for clearing up the air folks. Well, that answers my question. It is MySQL5 I'm using so I guess VARCHAR would be OK with the 65,000 character limit - I doubt I will go over that, or BLOB, I guess I can research the nitty-gritty details on my own. Oh, another thing - I am going to be the sole user of this, so security shouldn't be *much* of an issue (I'm not naive enough to rule out the risk of someone else gaining access to the posting form) but what is, generally, a better method of styling my input. Should I code some kind of BB style app, or, as I am going to be the sole user, should I just go ahead and stick in the normal HTML tags? I know allowing unformatted HTML input isn't always a great idea, but I just wondered what your opinions were? And, fenway, can you clear up on why TEXT is evil =P Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/98227-to-blob-or-varchar/#findComment-503781 Share on other sites More sharing options...
fenway Posted March 29, 2008 Share Posted March 29, 2008 TEXT is evil because it silently forces mysql to make a temporary table for group by / sorting operations... amongst other evil things. Quote Link to comment https://forums.phpfreaks.com/topic/98227-to-blob-or-varchar/#findComment-503905 Share on other sites More sharing options...
141n Posted March 29, 2008 Author Share Posted March 29, 2008 Fair enough, sounds like it could give me more headaches than I could do with just now =P Quote Link to comment https://forums.phpfreaks.com/topic/98227-to-blob-or-varchar/#findComment-503949 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.