I was getting strange chars and wrote this to clean them up, change it to suite your needs
PHP Code:
$sqlaa = @mysql_query("SELECT * FROM users_data WHERE user_county LIKE 'Â%'");
if(mysql_numrows($sqlaa) == '0'){
echo 'nothing to clean up';
}
else{
while ( $row = mysql_fetch_array($sqlaa) ) {
// echo $row["ct"].'<br>';
if ( preg_match('/^Â/', $row["user_county"]) ) {
echo $row["user_county"].' is changed to<br>';
// $out = ereg_replace("[^[:alpha:]]", "", $row["ct"]);
$out=preg_replace("/[^a-z \d]/i", "", $row["user_county"]);
$out = trim($out);
echo $out.'<br><br>';
$uid = $row["user_id"];
$sql2 = "UPDATE users_data SET
user_county = '$out'
WHERE user_id = '$uid'";
if (mysql_query($sql2)) {
// echo('<p>Database was cleaned up.</p>');
} else {
die('<p>Error cleaning Database: ' .
mysql_error() . '</p>');
}
}// preg_match
// else {echo 'Nothing to clean up';}
}// end sql while
}//else
hth
Bookmarks