oracle259 Posted September 23, 2006 Share Posted September 23, 2006 Basically, i'm writing a function that would check a userid for profanity similar to msn and yahoo userid filters so for example [b]f-shit.4m[/b] would not be accepted as a proper userid (also userids must start with a letter and can only contain letters, numbers, hyphens, underscores and dots). Anyway, the banned words would be stored in a mysql database and userid passed by the form would be checked against it. The problem is i need to know if im on the right track with the following code:<?php$sql = "SEARCH profanity FROM filter";$result = @mysql_query($sql);while ($words = @mysql_fetch_array($result, MYSQL_BOTH) {$profanity[] = $words[profanity];}$kill_characters = array ('.', '-', '_');$kill_num = range(0,9);$kill_all = array_merge($kill_num, $kill_characters);$userid = str_replace($kill_all, '' ", $userid);$obscene = $profanity[];foreach ($obscene as $obscenities) { if (stristr(trim($userid), $obscenities)) { $match = similar_text($userid, $obscenities, $percent); $percent = round($percent, 2); if ($percent >= '50') { echo "Sorry, username $userid is too vulgar. Please select another username.";} else {echo "Congratulations, username $userid is available.";}} else {echo "Congratulations, username $userid is available.";}}?>Where am i going wrong? ??? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.