Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to put too much data into mysql TEXT data type

Let's say that I have a html form (actually I have an editor - TinyMCE) which through PHP inserts a bunch of text into Mysql table.

I want to know the following:

If I have TINYTEXT data type in Mysql column - what happens if the user tries to put more text than 255 bytes into Mysql table??

Does the application save first 255 bytes and "cuts off" the rest? Or does nothing get saved into Mysql table and mysql issues a warning?? Or none of the above?

Actually, what I want and intend to do is the following: Limit the size of user form input by setting the column data type in Mysql to TEXT data type, which can hold maximum of 64 KB of text. I want to limit the amount of text that gets passed from user to database, so that user can't put too much data to the server at once.

So, basically, I want to know what happens, if the user puts more text through TinyMCE editor than 65535 bytes, assuming TEXT data type in mysql table.

like image 256
Matjaž Lojen Avatar asked Sep 13 '12 20:09

Matjaž Lojen


1 Answers

MySQL, by default, truncates the data if it's too long, and sends a warning.

SHOW WARNINGS;
Data truncated for foo ..

Just to be clear: the data will be saved, but you will be missing the part that was too large.

like image 94
Nim Avatar answered Oct 13 '22 01:10

Nim