Fabian Hasan
Fabian Hasan

Reputation: 1

Mysql db doesnt save text if its too long

My problem is pretty much decribed with the title! I have this code that inserts data to the db:

<?php
require_once 'connection.php';
$pName = $_POST['scriptName'];
$pCode = $_POST['code'];
$group = $_POST['group'];
$descri = $_POST['descr'];
$lang = $_POST['lang'];
$date = date("Y-m-d");
$updateq = "INSERT INTO code_tb (id, Script_Name, Description, Code, Language, Date) VALUES ('NULL', '$pName','$descri', '$pCode', '$lang', '$date')";
$result=mysql_query($updateq);
echo "$pName . $pCode . $group . $descri . $lang . $date";
?>

The Code field in my database is of type text.

When the code is too long it doesn't get saved in the db and I am not getting any error at all! If i shorten up the text string it works!

Might this be a stupid beginner mistake?

Upvotes: 0

Views: 1084

Answers (1)

Gidon Wise
Gidon Wise

Reputation: 1916

http://dev.mysql.com/doc/refman/5.0/en/storage-requirements.html

here are the limits:

text is 2^16 <--- pretty big.

longtext is 2^32 <--- huge

seems unlikely that you are sending more than a LONGTEXT's gigs of data into an sql statement.

so:

  1. find out the exact length that causes the problem.
  2. see what's going on in the string at around that length.
  3. try running the query in the mysql client.
  4. the bug might be something unexpected.

Upvotes: 1

Related Questions