Copy text from word (copy - past) gives error in control field (html editor)

I have a form that updates multiple records t once in a table containing multiple text fields .
i use a form so users can update that fields.
in the form i have several html editor fields where users can fill in ther text.

i all goes well exept when a user copy and pasted text from a word file. then the whole form does’nt updat e and gives an error.

i use the following script onvalidateSuccces

// zet field STUDENT (double select) om in string

$module = “{module_edit}”;

$module_var = (explode(’,’,$module));

// Loop for elke var uit de string en vult tabel ILP_rooster aan met edit gegevens

foreach ($module_var as $wk_id)

{

/**

  • // edit teksten van speciefieke modulen
    */

// SQL statement parameters
$update_table = “ILP_rooster”; // Table name
$update_where = “wk_id = ‘$wk_id’”; // Where clause
$update_fields = array( // Field list, add as many as needed
“wk_afb = ’ {wk_afb}’”,
“wk_doel = ‘{wk_doel}’”,
“wk_omschrijving = ‘{wk_omschrijving}’”,
“wk_faciliteiten = ‘{wk_faciliteiten}’”,
“wk_url = ‘{wk_url}’”,
“wk_opstelling = ‘{wk_opstelling}’”,
“wk_ict_ond = ‘{wk_ict_ond}’”,

);

// Update record
$update_sql = ‘UPDATE ’ . $update_table
. ’ SET ’ . implode(’, ', $update_fields)
. ’ WHERE ’ . $update_where;
sc_exec_sql($update_sql);

}

any suggestions

You need to clean all the Crap that comes within that word paste.

thanks for the reply. it send me on a path.

I noticed that when you use a form. all text from ms word is well interpreted and the save of the record went well. it’s a problem in the control app that causes the problem. even copy it in source code leaves a problem.

You can swap out the SC text editor with FCKeditor and it has a Paste From Word option on it that does all the work for you.

Yes, i’ve red that’s somewhere. Buurt have no Idea hotel to do that’s in scriptcase. Ik dont understand how you integrate the libs

function SanitizeFromWord($Text = '') 

{
$chars = array(
130=>’,’, // baseline single quote
131=>‘NLG’, // florin
132=>’"’, // baseline double quote
133=>’…’, // ellipsis
134=>’’, // dagger (a second footnote)
135=>’
*’, // double dagger (a third footnote)
136=>’^’, // circumflex accent
137=>‘o/oo’, // permile
138=>‘Sh’, // S Hacek
139=>’<’, // left single guillemet
140=>‘OE’, // OE ligature
145=>’’’, // left single quote
146=>’’’, // right single quote
147=>’"’, // left double quote
148=>’"’, // right double quote
149=>’-’, // bullet
150=>’-’, // endash
151=>’–’, // emdash
152=>’~’, // tilde accent
153=>‘™’, // trademark ligature
154=>‘sh’, // s Hacek
155=>’>’, // right single guillemet
156=>‘oe’, // oe ligature
159=>‘Y’, // Y Dieresis
169=>‘©’, // Copyright
174=>‘®’, // Registered Trademark
173=>’-’ , //weird hyphen
32=>’ ‘,
8194=>’ ’
);

foreach ($chars as $chr=>$replace) {
	$Text = str_replace(chr($chr), $replace, $Text);
}
$text2 = clean_more($Text);
$text3 = convert_smart_quotes2($text2); 
$text4 = str_replace("&#8194;", " ", $text3);
//$text4 = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x{FFFE}\x{FFFF}]/u', "\xEF\xBF\xBD", $text3);
$text5=removeslashes($text4);
return $text5;

}
/////
function removeslashes($string)
{
$string=implode("",explode("\",$string));
return stripslashes(trim($string));
}
///
function clean_more($string)
{
$unwanted_array = array( ‘"’=>’’, ‘Š’=>‘S’, ‘š’=>‘s’, ‘ž’=>‘z’, ‘À’=>‘A’, ‘Á’=>‘A’, ‘Â’=>‘A’, ‘Ã’=>‘A’, ‘Ä’=>‘A’, ‘Å’=>‘A’, ‘Æ’=>‘A’, ‘Ç’=>‘C’, ‘È’=>‘E’, ‘É’=>‘E’,
‘Ê’=>‘E’, ‘Ë’=>‘E’, ‘Ì’=>‘I’, ‘Í’=>‘I’, ‘Î’=>‘I’, ‘Ï’=>‘I’, ‘Ñ’=>‘N’, ‘Ò’=>‘O’, ‘Ó’=>‘O’, ‘Ô’=>‘O’, ‘Õ’=>‘O’, ‘Ö’=>‘O’, ‘Ø’=>‘O’, ‘Ù’=>‘U’,
‘Ú’=>‘U’, ‘Û’=>‘U’, ‘Ü’=>‘U’, ‘Ý’=>‘Y’, ‘Þ’=>‘B’, ‘ß’=>‘Ss’, ‘à’=>‘a’, ‘á’=>‘a’, ‘â’=>‘a’, ‘ã’=>‘a’, ‘ä’=>‘a’, ‘å’=>‘a’, ‘æ’=>‘a’, ‘ç’=>‘c’,
‘è’=>‘e’, ‘é’=>‘e’, ‘ê’=>‘e’, ‘ë’=>‘e’, ‘ì’=>‘i’, ‘í’=>‘i’, ‘î’=>‘i’, ‘ï’=>‘i’, ‘ð’=>‘o’, ‘ñ’=>‘n’, ‘ò’=>‘o’, ‘ó’=>‘o’, ‘ô’=>‘o’, ‘õ’=>‘o’,
‘ö’=>‘o’, ‘ø’=>‘o’, ‘ù’=>‘u’, ‘ú’=>‘u’, ‘û’=>‘u’, ‘ý’=>‘y’, ‘þ’=>‘b’, ‘ÿ’=>‘y’,‘½’=>‘1/2’,‘¾’=>‘3/4’,‘¼’=>‘1/4’,’<’=>’< ‘,’>’=>’> ‘);
$str = strtr( $string, $unwanted_array );
$str2 = str_replace("’", ‘`’, $str);
return($str2);
}
///
////
function convert_smart_quotes2($string)
{
$search = array(chr(145),
chr(146),
chr(147),
chr(148),
chr(151));
$replace = array("’",
“’”,
‘"’,
‘"’,
‘-’);
return str_replace($search, $replace, $string);
}

1 Like

thanks i’ll give it a try and let you know :blush: