List:General Discussion« Previous MessageNext Message »
From:RACHEL DAWN NAPPER Date:December 5 2003 1:21am
Subject:error when inserting long string from cgi
View as plain text  
Hi there,

I am attempting to insert a string into a longtext field (from a CGI
program using the C API) and I keep getting an error message. The string
is not that long actually, 78,069 characters. (Originally this was
mediumtext, but I changed it to longtext as I debugged this problem.)

The command is:
INSERT INTO my_table_name (integer_field, longtext_field) VALUES (24144,
"x24144(5000)14799:1.000000~23534:1.000000~...24114:1.000000~")

The error message is:
MySQL error inserting data in save_neighbors_of_favorites: You have an
error in your SQL syntax near
'"x23973(5000)79397:1.000000~92558:1.000000~216160:1.000000~263178:1.000000~27521'
at line 1.

The error occurs when the string I want to insert has about 2000 or more
characters. The error goes away when the string is shorter than that.

So this seems to be a problem with the length of the string. I keep thinking
that the syntax error is caused because the INSERT command is being
truncated because it's too long. I have tried resetting the net_buffer_size
and max_allowed_packet variables. Currently, net_buffer_size is set to
1,407,552 and max_allowed_packet is 3,144,704. (Actually, I tried to set
both to 3M doing /usr/bin/safe_mysqld  -O max_allowed_packet=3145728 -O
net_buffer_length=3145728 &
but end up being the sizes I listed above. Maybe I am doing something wrong
here?)

I am running MySQL 3.23.58 on Red Hat 8.0 with 128M of memory.

I don't think any of the non-integer characters need to be escaped. I have
tried escaping the string anyway just in case using mysql_escape_string()
(I know I'm supposed to use mysql_real_eascape_string(), but for some
reason it
causes my program to seg fault) and I get the same error.


I would very much appreciate any help or suggestions.
Thanks!
Rachel

Thread
error when inserting long string from cgiRACHEL DAWN NAPPER5 Dec