I want to make a function that will censor what a person post on a message board I made but for some reason its not working if anyone will please read over this code and tell me why it might not be working:
Code:
function censor ($post) {
global $dbhost, $dbuser, $dbpass, $db;
$sql_server = @mysql_connect($dbhost,$dbuser,$dbpass) or die("<b>Fatal MySQL Error: </b> We were unable to contact the MySQL server. <a href=\"mailto:$systemadmin\">Contact system admin.</a>");
mysql_select_db($db,$sql_server) or die("<b>Fatal MySQL Error: </b> We were unable to query the MySQL server. <a href=\"mailto:$systemadmin\">Contact system admin.</a>");
$Censor_query = mysql_query("SELECT * FROM forum_censor");
$query = mysql_fetch_array($Censor_query);
$censor = "$query[censor]";
$replace = "CENSORED";
$lookup = @explode(",",$censor);
$zie = @sizeof($lookup)-1;
while($zie > -1) {
$a = "$dont[$zie]";
for($i=1; $i <= @strlen($a); $i++) {
$nono .= "$replace";
}
$post = @eregi_replace($a, substr($a,0,0)."$nono", $post);
$nono = "";
$zie--;
return $post;
}
}