|
|
|
|
![]() ![]() |
Apr 17 2006, 11:24 AM
Post
#1
|
|
|
I'm back... well, sort of. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 697 Joined: 26-December 05 From: somewhere in the middle of nowhere Member No.: 16,226 ![]() |
hey everyone! i just started using mysql so i could integrate it on my site. i'm trying to create a comment section and store the data on mysql. i've defined my table having a field type of varchar with max value 5000. but when i created it on phpmyadmin on my free hosting account, it said that the maximum value for a varchar is just 255. it said that i should use a blob. what is it and how can i access the data using php? i've searched from the net and it said that blob is used for images and document data. and i also found out that the data stored in a blob is a byte... so if i can use blob, how can i convert a text/string to a blob and vice versa. hmm... i'm confused...
oh make that binary, not byte. sorry. |
|
|
|
Apr 17 2006, 04:13 PM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 106 Joined: 1-April 06 Member No.: 21,148 |
Just consider blobs to be longer versions of varchars and use them in exactly the same way. In the phpAdmin or the mysqlAdmin (I don't remember which, as I usually do it manuall) you can change the type of field from varchar to blob. Do that, and then treat the rest exactly the same.
|
|
|
|
Apr 17 2006, 05:43 PM
Post
#3
|
|
|
Trap Grand Marshal Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,203 Joined: 25-March 05 Member No.: 4,883 |
MySQL treat data unique. Hence there is a difference between Blob and Text. Text simply means a text string stored as orginal, not in binary, whereas a blob is a text string stored as a binary.
You can find more information about data types on the MySQL deocumentations. http://dev.mysql.com/doc/refman/5.0/en/blob.html |
|
|
|
Apr 18 2006, 12:32 AM
Post
#4
|
|
|
Administrator ![]() Group: Admin Posts: 1,479 Joined: 11-June 04 From: Somewhere in Time & Space. Member No.: 1 |
BLOB and TEXT type as explained in MySQL Language Reference.
QUOTE A BLOB is a binary large object that can hold a variable amount of data. The four BLOB types TINYBLOB, BLOB, MEDIUMBLOB, and LONGBLOB differ only in the maximum length of the values they can hold.
The four TEXT types TINYTEXT, TEXT, MEDIUMTEXT, and LONGTEXT correspond to the four BLOB types and have the same maximum lengths and storage requirements. The only difference between BLOB and TEXT types is that sorting and comparison is performed in case-sensitive fashion for BLOB values and case-insensitive fashion for TEXT values. In other words, a TEXT is a case-insensitive BLOB. |
|
|
|
Apr 18 2006, 02:44 AM
Post
#5
|
|
|
I'm back... well, sort of. ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 697 Joined: 26-December 05 From: somewhere in the middle of nowhere Member No.: 16,226 ![]() |
so i could use TEXT instead of BLOB in storing the comments? if so, how long is the maximum length for a TEXT in the free hosting accounts? and if ever i am to use a BLOB, how can i convert it to a non-binary form using php and vice versa?
|
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 13th October 2008 - 09:41 PM |