Hi, I want to insert/update a very long text into database but it doesn't work. I use longtext in database. it works for shorter text. when i update with $_post['textarea'] the value remain the same (empty or previous shorter text added before). it also work on my pc but not on the server. i imported there my database and the same thing. anyone have any idea?
$val = stripslashes($_POST['text_atricol']); if(get_magic_quotes_gpc()) { $val = stripslashes($_POST['text_atricol']); } $val = str_replace('\\', '\', $val); $val = mysql_real_escape_string($val); $q = "UPDATE articole SET articol_html = '$val' WHERE id = $_POST[id]"; $sql->query($q, SQL_NONE); Table Information Storage engine: MyISAM Charset: latin1 Rows: 2 Size: 240 B Overhead: 0 B Auto Increment: 114 let me know if you need more info
mysql_query("UPDATE ......) or die(mysql_error(); try that and maybe you will find easier what is the problem. It should tell you. I think the size of the field is not declared right so there is not enough space for the text. Maybe some versions diferences on the DB server or something like that. Hope this helps
this is the error 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 'apprécier à l'aune des ambitions qu'elle prétend poursuivre' at line 4 the apprécier à l'aune des ambitions qu'elle prétend poursuivre' is a part of text. i cannot use htmlspecialchars because a use an text editor.
i think your db charset is not right. try iconv to change variables charset to your dbs charset. for example; UTF-8 to ISO-8859-1 $variable = iconv("UTF-8","ISO-8859-1//TRANSLIT",$variable); PHP:
mysql_real_escape_string should take care of any issues with characters. I agree with using a BLOB instead. But, could you var_dump($q); PHP: before you insert, and post what it says?
It says null even after the form is submitted? $q = "UPDATE articole SET articol_html = '$val' WHERE id = $_POST[id]"; var_dump($q); $sql->query($q, SQL_NONE); PHP:
seams that it's working now. this is the code: if(get_magic_quotes_gpc()) { $val = stripslashes($_POST['text_atricol']); } $val = str_replace('\\', '\', $val); $val = mysql_real_escape_string($val); $val = iconv("UTF-8","ISO-8859-1//TRANSLIT", $val); mysql_query("UPDATE articole SET articol_html = '$val' WHERE id = '$_POST[id]'") or die(mysql_error()); PHP: thanks a lot for your effort.