RE: [PHP-DB] Text corruption when storing to MySql
$content = str_replace($crap,$clean,$submitted_text); :) (I hadn't even noted you missed any at first) - Martin Norland, Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -Original Message- From: Roger Spears [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 20, 2004 3:41 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Text corruption when storing to MySql I missed a variable in my previous postshould have been this: $submitted_text = $_POST['textFromForm']; function clean_ms_word($submitted_text) { $crap = array(chr(0x82),chr(0x83),chr(0x84),chr(0x85),chr(0x86),chr(0x87),chr(0x 88),chr(0x89),chr(0x8a),chr(0x8b),chr(0x8c),chr(0x91),chr(0x92),chr(0x93 ),chr(0x94),chr(0x95),chr(0x96),chr(0x97),chr(0x98),chr(0x99),chr(0x9a), chr(0x9b),chr(0x9c),chr(0x9f)); $clean = array('lsquor;','fnof;','ldquor;','ldots;','dagger;','Dagger;','', 'permil;','Scaron;','lsaquo;','OElig;','lsquo;','rsquo;','quot;', 'quot;','bull;','ndash;','mdash;','tilde;','trade;','scaron;','r saquo;','oelig;','Yuml;'); $content = str_replace($crap,$clean,$writing); return $content; } $usable = clean_ms_word($submitted_text); HTH, Roger -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Text corruption when storing to MySql
check both single and double quotes replace them with ('') and () respectively, try mysql_real_escape_string() functions bastien From: Gaby T. [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: [PHP-DB] Text corruption when storing to MySql Date: Wed, 20 Oct 2004 12:49:51 -0700 I am running into a problem where as I want to store test form a text field to a database (MySql in this case, sql type text). Apparently, if people are cutting and pasting text from another document (typically MS WORD) into the textfield, the text gets only partially saved. I am assuming wierd characters are being introduced in this manner (I definitively know this is a problem with rounded quotes) and although I am using the basic addslashes function, it's not enough. Has anyone seen this before and is there a fix? Thanx Gaby -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Text corruption when storing to MySql
Gaby T. wrote: I am running into a problem where as I want to store test form a text field to a database (MySql in this case, sql type text). Apparently, if people are cutting and pasting text from another document (typically MS WORD) into the textfield, the text gets only partially saved. I am assuming wierd characters are being introduced in this manner (I definitively know this is a problem with rounded quotes) and although I am using the basic addslashes function, it's not enough. Has anyone seen this before and is there a fix? Thanx Gaby I believe Tom Rodgers from the PHP general list provided this answer when I posted a similar question about a year ago... $submitted_text = $_POST['textFromTextArea']; function clean_ms_word($writing) { $crap = array(chr(0x82),chr(0x83),chr(0x84),chr(0x85),chr(0x86),chr(0x87),chr(0x88),chr(0x89),chr(0x8a),chr(0x8b),chr(0x8c),chr(0x91),chr(0x92),chr(0x93),chr(0x94),chr(0x95),chr(0x96),chr(0x97),chr(0x98),chr(0x99),chr(0x9a),chr(0x9b),chr(0x9c),chr(0x9f)); $clean = array('lsquor;','fnof;','ldquor;','ldots;','dagger;','Dagger;','','permil;','Scaron;','lsaquo;','OElig;','lsquo;','rsquo;','quot;','quot;','bull;','ndash;','mdash;','tilde;','trade;','scaron;','rsaquo;','oelig;','Yuml;'); $content = str_replace($crap,$clean,$writing); return $content; } $usable = clean_ms_word($submitted_text); This has worked wonderfully for my applications! Thanks, Roger -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Text corruption when storing to MySql
I missed a variable in my previous postshould have been this: $submitted_text = $_POST['textFromForm']; function clean_ms_word($submitted_text) { $crap = array(chr(0x82),chr(0x83),chr(0x84),chr(0x85),chr(0x86),chr(0x87),chr(0x88),chr(0x89),chr(0x8a),chr(0x8b),chr(0x8c),chr(0x91),chr(0x92),chr(0x93),chr(0x94),chr(0x95),chr(0x96),chr(0x97),chr(0x98),chr(0x99),chr(0x9a),chr(0x9b),chr(0x9c),chr(0x9f)); $clean = array('lsquor;','fnof;','ldquor;','ldots;','dagger;','Dagger;','','permil;','Scaron;','lsaquo;','OElig;','lsquo;','rsquo;','quot;','quot;','bull;','ndash;','mdash;','tilde;','trade;','scaron;','rsaquo;','oelig;','Yuml;'); $content = str_replace($crap,$clean,$writing); return $content; } $usable = clean_ms_word($submitted_text); HTH, Roger -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php