问题
im trying to save to my data base a long text (about 2500 chars) input by my users using a web form and passed to the server using php.
When i look in phpmyadmin, the text gets crop. How can i config my table in order to get the complete text? This is my table config:
CREATE TABLE `extra_879` (
`id` bigint(20) NOT NULL auto_increment,
`id_user` bigint(20) NOT NULL,
`title` varchar(300) NOT NULL,
`content` varchar(3000) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_user` (`id_user`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
Take a look of the field content that have a limit of 3000 chars, but the texts always gets crop at 690 chars. Thanks for any help!
EDIT: I found the problem but i dont know how to solve it. The query is getting crop always in the same char, an special char: ù
EDIT 2: This is the cropped query:
INSERT INTO extra_879 (id,id_user,title,content) VALUES (NULL,'1','Informazione Extra','
Riconoscimenti
Laurea di ingegneria presa a le 22 anni e in il terso posto della promozione
Diploma analista di sistemi ottenuto il rating massimo 20/20, primo posto della promozione.
Borsa di Studio (offerta dal Ministero Esteri Italiano) vinta nel 2010 (Valutazione del territorio attraverso le nueve tecnologie)
Pubblicazione di paper; Stima del RCS della nave CCGS radar sulla base dei risultati di H. Leong e H. Wilson. http://www.ing.uc.edu.vek-azozayalarchivospdf/PAPER-Sarmiento.pdf
Tesi di laurea: PROGETTAZIONE E REALIZZAZIONE DI UN SIS-TEMA DI TELEMETRIA GSM PER IL CONTROLLO DELLO STATO DI TRANSITO VEICOLARE E CLIMA (ottenuto il punteggio pi')
It gets crop just when the (ottenuto il punteggio più alto) phrase, just when ù appear...
EDIT 3: I using jquery + ajax to send the query
$.ajax({type: "POST", url: "handler.php", data: "e_text="+ $('#e_text').val() + "&e_title="+ $('#extra_title').val(),
回答1:
Answering to your updated question:
You're (apparently) trying to insert unicode text. And your table's charset is set to latin1. That's not gonna fly.
Change your table charset to utf-8.
ALTER TABLE extra_879 CONVERT TO CHARACTER SET utf8;
More info here.
回答2:
Try to change varchar(3000) to text (or longtext)
回答3:
Try changing the table charset to the charset that support special characters...
回答4:
If the query is getting cropped at the character ù then you may have to replace that character with it's escaped equivalent.
回答5:
There seems to be no reason why the content should be getting cropped. I tried running the INSERT statement below, with the special "ù" character and it ran successfully.
INSERT INTO extra_879 (id,id_user,title,content) VALUES (NULL,'1','Informazione Extra','
Riconoscimenti
Laurea di ingegneria presa a le 22 anni e in il terso posto della promozione
Diploma analista di sistemi ottenuto il rating massimo 20/20, primo posto della promozione.
Borsa di Studio (offerta dal Ministero Esteri Italiano) vinta nel 2010 (Valutazione del territorio attraverso le nueve tecnologie)
Pubblicazione di paper; Stima del RCS della nave CCGS radar sulla base dei risultati di H. Leong e H. Wilson. http://www.ing.uc.edu.vek-azozayalarchivospdf/PAPER-Sarmiento.pdf
Tesi di laurea: PROGETTAZIONE E REALIZZAZIONE DI UN SIS-TEMA DI TELEMETRIA GSM PER IL CONTROLLO DELLO STATO DI TRANSITO VEICOLARE E CLIMA (ottenuto il punteggio più alto')
What is the query that you have mentioned in EDIT 2? From where did you print it? If that query is actually running in the backend, it will always insert the cropped text because it itself doesn't contain the full text - it is missing the "ù" character and everything following it. Therefore, assuming that is the actual query, the cropping seems to be happening elsewhere.
I'm not sure how post requests are done in AJAX but is the data passed in the URL? If yes, I'll suggest you do a URL-Encode before sending the data.
回答6:
Already solve the problem, was an jquery problem. You can check the answer here: TinyMCE + Jquery + PHP + AJAX Special chars issue
来源:https://stackoverflow.com/questions/8862717/why-i-cant-save-a-long-text-on-my-mysql-database