-
Posts
119 -
Joined
-
Last visited
Never
Everything posted by oracle259
-
i'm not familiar with strpos how would i go about doing that.
-
ok. I have the following code. The problem is this, say $user = "bob.camsara and $reserved names are bob and sara the output would be %%%.camsara. my question is how can i modify the code to go through the entire result to get %%%.cam%%%%. [code] while ($res = @mysql_fetch_array($result)) { if (stristr(trim($user, $reserved)) { $length = strlen($reserved); for ($k = 1; $k <= $length; $k++) { $percent = "%"; } $newuser = eregi_replace($reserved, $percent, trim($user)); $percent = " "; } } echo $newuser; [/code]
-
How can i do multiple mysql loops without having to do while ( ) more than once
-
How can i improve on the following code [code] while ($res = @mysql_fetch_array($result)) { if (stristr(trim($user, $reserved)) { $length = strlen($reserved); for ($k = 1; $k <= $length; $k++) { $percent = "%"; } $newuser = eregi_replace($reserved, $percent, trim($user)); $percent = " "; } } echo $newuser; [/code] The problem is this, say $user = "bob.camsara and $reserved names are bob and sara the output would be %%%.camsara. Question how can i modify the code to go through the entire result to get %%%.cam%%%%.
-
How can i combine the similar_text() and levenshtein() functions to get a more accurate match percentage than similar_text() I tried [code] $match = similar_text($word1, $word2, $percent); $percent = round($percent, 1); if ($percent > 5) { $lev = levenshtein($word1, $word2); $count1 = strlen($word1); $count2 = strlen($word2); $cnt = ($count1/$count2) * $lev; $cnt = round($cnt, 1); if ($cnt > 1) { echo "fail"; } else { echo "pass"; } } else { echo "pass"; } [/code] but it fails to pass ass in asset because $percent = 0 and $cnt = 1.5 Please help
-
Im still a newbie so may be but doesnt hurt to do it
-
Not really...in php you can use the following code: [code] $match = similar_text($compare1, $compare2, $percent); $percent = round($percent, 0); echo $pecent; [/code] to get the percentage similarity between ass and assets. But the percent comes to 0 which is not accurate i want to know if there is a better way to achieve a more accurate figure.
-
You should also check the magic_quotes_gpc state (ie on or off) you can try something like this also you can tie ur mysql_real_escape_string tests into the function [code] function makesafe($string) { if (!isset($_REQUEST['$string']) || empty($_REQUEST['$string'])) { die ("Unauthorized action"); } if (!get_magic_quotes_gpc()) { $string = addslashes($_POST['$string']); } else { $string = $_POST['$string']; } $string = mysql_real_escape_string($string); return $string } [/code] Remember though, if you are going to use empty $string can't be 0 or it will return empty.
-
apart from the built in similar_text() function how do i go about testing the similarity between two words.
-
i think this one is solved thanks
-
thanks for the tip...but why the " "
-
I really hope u guys can help me on this one ???. [code] $match = str_replace("*", '', $string); $match = strlen($match); if ($match == 0) { return False; } else { return True; } [/code] From the code you can see the problem clearly that if no *** are present in the $string, $match = strlen($match) also returns 0 which does not work for me. How do i change this code to make sure that $match = 0 only when *** are present in the $string and replaced. Thanks.
-
How do i tell the PHP script what port to use to connect to the mysql db. I have been trying [code]$conn = mysql_connect($dbhost:$dbport, $dbuser, $dbpwd);[/code] but i doesnt seem to work. Help
-
Sorry my bad it worked great thanks alot. :)
-
Unfortunately it did not work i think because of the missing foreach statement [code]function language_filter($string) { $obsenities = mysql_query("SELECT * FROM langfilter") or die(mysql_error()); while($row = mysql_fetch_array($obsenities)){ $curse_word = $row['word']; if (stristr(trim($string),$curse_word)) { $length = strlen($curse_word); for ($i = 1; $i <= $length; $i++) { $stars .= "*"; } $string = eregi_replace($curse_word,$stars,trim($string)); $stars = ""; } } return $string; }[/code]
-
Pretty much this [code]$sql="CREATE TABLE `langfilter` ( `id` bigint(20) unsigned NOT NULL auto_increment, `word` varchar(225) NOT NULL default '', `tag` char(1) NOT NULL default '1', PRIMARY KEY (`id`) ) TYPE=MyISAM"; $result = dbQuery($sql) or do_error("Couldn't execute SQL: $sql". mysql_error()); [/code]
-
[quote]I guess you first need to decide how you will store the banned words in your database? A table for banned words then each word stored as a separate row? or a single row entry with all the words, separated by commas or line breaks or something like that. Once you have decided that, we can move on to making a script to check[/quote] I used the first approach.. which doesnt seem to be working too well. but thats the best way to keep adding to the database over time.
-
How can i modify the language filter tutorial code to work with a mysql database instead of a flat text file. I have tried several times with no luck. [code]<?php function language_filter($string) { $obscenities = @file("path/to/your/file/foul_language.txt"); foreach ($obscenities as $curse_word) { if (stristr(trim($string),$curse_word)) { $length = strlen($curse_word); for ($i = 1; $i <= $length; $i++) { $stars .= "*"; } $string = eregi_replace($curse_word,$stars,trim($string)); $stars = ""; } } return $string; } ?> [/code]
-
I read the tutorial before i made the post but it only helped so much i think i need help conceptualizing how it should work because i'm stuck on my own.
-
I have been tryin to figure out this puzzle for the past few days. But no cigar. How do i go about creating a username filter like msn which check usernames against a database of banned words and tells the user to change the username entered if it contains a banned word. Any help would be appreciated.
-
How do i go about checking if a word stored in a database is included in word submitted from a form. For example: form input = clansman database input = clan for far i have tried the following: while ($rec = mysql_fetch_array($result)) { $database[] = $rec[word]; } foreach ($database as $db) { if (stristr(trim($userinput), $db)) { echo "$db is a subsect of $userinput"; } } But it produces alot of loops of the echo statement. What am i doing wrong
-
how do i eliminate whitespaces from a string for example $string = "c l u s t e r";
-
How do i create an array from a mysql result. So far i have tried this while ($res = mysql_fetch_array($result, MYSQL_BOTH) { $link[] = $res[item]; } echo $link[]; but that doesnt seem to work. any help would be appreciated.
-
Im not certain if this belongs in the php or mysql forum but here goes. How can i create a page that will display a loading graphic <eg [move][b]Loading.... [/b] [/move] or [move][b]Processing.... [/b][/move] > until a mysql query has executed and then it stops and displays the query. I have seen it all over the web but cant get my mind around how i would approach developing it. Basically, it would allow me to run complex queries without the user thinking that the program has timedout or gettting frustrated. thanks
-
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? ???