[SOLVED]String too long..

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
aye
Forum Commoner
Posts: 25
Joined: Wed Apr 11, 2007 9:02 am

[SOLVED]String too long..

Post 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
Last edited by aye on Wed Apr 11, 2007 1:20 pm, edited 1 time in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
aye
Forum Commoner
Posts: 25
Joined: Wed Apr 11, 2007 9:02 am

Post 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?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
aye
Forum Commoner
Posts: 25
Joined: Wed Apr 11, 2007 9:02 am

Post by aye »

thanks a lot for all your help! works great now :)
Post Reply