Page 1 of 1

[SOLVED]String too long..

Posted: Wed Apr 11, 2007 10:29 am
by aye
Hi everyone!
i have this function that reads a whole lot of data with file_get_contents() and should then put i into a mysql table (TEXT column). It seems however that the string is too long.. if you would run mysql_error() during the query, you will get the following error message:
[quote]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '¡&‘ðùá¨ì{Ÿ‚Q{Š}x

Posted: Wed Apr 11, 2007 10:45 am
by volka
apply mysql_real_escape_string before using the data string in a sql statement.

If the string were too long mysql would have told you so.

Posted: Wed Apr 11, 2007 11:44 am
by aye
thanks for your help, forgot that :)

Anyhow, it seems like the string is too long still.. now i get the following error instead: "Got a packet bigger than 'max_allowed_packet' bytes". So, my new question: how do you change max_allowed_packet? im on a dedicated server, so access should be no problem

Update: nevermind, i managed to change the max_allowed_packet size by editing my.cnf.
Now i have a new problem though. I'm going to put all the data into a text column, but only a very small amount of the complete text file (~13mb) is put into the column. Seems like there is some restriction of how big a text column can get (only 2-4% of the document is stored). Can i change this somehow?

Posted: Wed Apr 11, 2007 12:49 pm
by pickle
Change the column from text to mediumtext or longtext. Check the MySQL docs for seeing what the size limit is for the different column types.

Posted: Wed Apr 11, 2007 1:19 pm
by aye
thanks a lot for all your help! works great now :)