Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store articles in mysql database

Tags:

php

mysql

I need to store the articles which are submitted by my website users.

1.The articles will be 100 to 200 lines in length.

2.The articles will have html tags.For example:

"<br>"

Tell me which "TYPE" should i select when creating the Column in the MYSQL Database and tell me the "LENGTH" too.

I tried VARCHAR but it is not working.

like image 679
softleaks Avatar asked Mar 29 '13 11:03

softleaks


People also ask

Can you store files on MySQL?

A Binary Large Object ( BLOB ) is a MySQL data type that can store binary data such as images, multimedia, and PDF files.

Can we store audio in MySQL?

BLOB Datatype in MySQL In MySQL, the BLOB data type represents a binary large object and can be used to store binary media data, such as audio or video links, images, or files.

Which is better VARCHAR or TEXT in MySQL?

In most circumstances, VARCHAR provides better performance, it's more flexible, and can be fully indexed. If you need to store longer strings, use MEDIUMTEXT or LONGTEXT, but be aware that very large amounts of data can be stored in columns of these types.

How is data stored in MySQL?

MySQL stores each database (also called a schema) as a subdirectory of its data directory in the underlying filesystem. When you create a table, MySQL stores the table definition in a . frm file with the same name as the table. Thus, when you create a table named MyTable , MySQL stores the table definition in MyTable.


2 Answers

Use TEXT or MEDIUMTEXT or LONGTEXT column types

TEXT column can store 65,535 characters MEDIUMTEXT can store 16,777,215 characters LONGTEXT can store 4,294,967,295 characters

Please note that, if characters are multi-byte characters (like UTF-8), then these numbers are less.

like image 127
Amit Avatar answered Oct 04 '22 20:10

Amit


use TEXT type when storing long text.

like image 24
hodl Avatar answered Oct 04 '22 22:10

hodl