As a work around i came up with this function, dunno maybe it will help someone else
PHP Code:
function bad_char_strip($doit) {
$doit = preg_replace("/\W+/", '', $doit);
$doit = preg_replace("/\s+/", '', $doit);
return($doit);
}
$lsusername = bad_char_strip($lsusername);
$charname = bad_char_strip($charname);