0

I want to store particular text field in database in the html equivalent form.I have used the PHP function

$str = htmlentities($str, ENT_QUOTES, "UTF-8");

where particular column in database related to $str variable has Column Charset: utf8 & Column Collate: utf8_bin. but value is stored in same BLOB form.

0

3 Answers 3

1

BLOB in terms of MySQL is a data type and is different than your character encoding (utf8) or collation. If you want to change the data type, you will have to query your database with...

ALTER TABLE tbl_name MODIFY col_name TEXT;

or VARCHAR() or whatever you want to change it to.

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

2 Comments

but BLOB is automatically created. I have made text type for particular column with the Column Charset: utf8 & Column Collate: utf8_bin but while showing this or browsing this its showing like this [BLOB - 6 B].
That's because your Column Charset: utf8 and Column Collate: utf8_bin assignments aren't correct for what you are trying to do. When you are creating a new table column, you need to query with ALTER TABLE tbl_name ADD col_name TEXT and your data type will be TEXT. The column character set and collation will automatically assign to the the table default.
1

If you want text in the database, don't use the BLOB field type. Use TEXT, VARCHAR, etc. BLOB is for binary data and nothing you do in PHP is going to change the way it's stored in the database.

1 Comment

BLOB may very well be used for text data as well, but no charset translations will be applied.
0

If you're storing large HTML pages, use LARGETEXT()

Comments

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.