[thelist] SQL Insert via PHP (long text problem)

Duarte Pyrrait duarte.pyrrait at gmail.com
Fri Sep 22 10:06:06 CDT 2006

Hello everyone,

I'm having trouble inserting a long text into a field of a data table.
If  the text is too long, the insert statement don't work.
I think the maximum size for text is 8000 characters but the MySQL database
don't accept a 3000 characters text.
The problem only happens at the client remote server. I´ve tryed in my local
server and everything works as supposed.

This is the data table:

  `id` int(11) NOT NULL auto_increment,
  `title` text NOT NULL,
  `text` text NOT NULL,
  PRIMARY KEY  (`id`)
) ;

And this is the PHP code:

// Variables For Insert
$ttl = "Lorem Ipsum";
$txt = "The long text.............";

// The Insert Stuff
$connect = mysql_select_db("mydatabase", mysql_connect("server", "user",
"pass")) or die("Problem!!!");
$sql = "insert into news(title,text) values('$ttl','$txt')";
$result = mysql_db_query("mydatabase", $sql);

If the text is short the line is inserted at the database. If the text is a
bit long the line isn't inserted.
I'm sure this is related to the hosting service because this work in other

If someone faced the same problem and could help me pointing the problem or
a solution would be great.

Thanks in advance.

More information about the thelist mailing list