0

Cuz, I did it unintentionally. After reading wikipedia I understand the "binary large object" is for large media files, and I'm not saving a media file.

So how does data get stored this way? What's wrong with this setup to display text as BLOB in phpmyadmin?

the MySql field from phpmyadmin,
Field = 'first_name'
Type = text
Collation = latin1_bin
Null = No
Default = None

The php code, $insertName = "INSERT INTO name(first_name,last_name)VALUES('$firstName','$lastName')";
$dbSuccess_1 = mysql_query($insertName,$connectID) or die ("ERROR_1 - Unable to save to MySQL".error_get_last().mysql_error($connectID));

3
  • 2
    What is your question? I don't understand. Commented Aug 25, 2010 at 19:11
  • If you are saying you want to store binary files in your database, that is wrong. You should store these on your file system and in your database store a reference to the file on the system. Commented Aug 25, 2010 at 19:14
  • I rewrote the q a little clearer... Commented Aug 25, 2010 at 19:21

2 Answers 2

1

If you're asking how to change a BLOB column to TEXT you would use a query similar to this:

ALTER TABLE `name`  
    CHANGE COLUMN `first_name` `first_name` TEXT NULL FIRST
    ,CHANGE COLUMN `last_name` `last_name` TEXT NULL AFTER `first_name`;

You can use PHPMyAdmin to make the change even easier.

Sign up to request clarification or add additional context in comments.

2 Comments

IIRC phpMyAdmin(at least older versions) showed both TEXT and BLOB fields as "BLOB". If you created them as text there is probably nothing wrong.
[I deleted my previous comment to this post, because when I reread my question, I realized this answer is exactly correct.] While phpMyAdmin still shows these original tables as TEXT, when I uploaded to a different server, and created the tables in the same manner, the text displays correctly on a different server. I can only conclude, either some other parameter is altering the TEXT data to BLOB or the table is corrupt in some manner.
0

TEXT and BLOB are essentially identical, except that TEXT fields are subject to character set limitations (and character set is taken into account while sorting/grouping the fields), while BLOBs are stored verbatim as a sequence of bytes and will not be transformed.

Relevant docs: http://dev.mysql.com/doc/refman/5.0/en/blob.html

2 Comments

Are you saying the Collation I've set is causing the BLOB to be set even though I selected TEXT when I created the table?
No, that would defeat the purpose of a TEXT field. Possibly it's phpmyadmin treating text as blob for display purposes. Do you have access to the normal mysql console? If you can, get into that and try doing a show create table tablename or describe tablename and see what's reported there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.