PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$result = $db->sql_query("SELECT postBody FROM posts WHERE status='1'");
while($row = mysql_fetch_array($result)){
similar_text(preg_replace("/\r\n|\n|\r/", "", strtolower($postform)), preg_replace("/\r\n|\n|\r/", "", strtolower($row[0])), $similarity_pst);
if (number_format($similarity_pst, 0) > 90){$flag = "message already sent"; break;}
}
Target idea: check if a form post message is already in database or any similar post message(I picked a 90% margin)
The code above works but it slow down my machine (specialy if the post is huge: more 10000chars) and it will take a lot of time if several posts are already in database...
Do you have any idea to develop this in a fast mode ?
Last edited by pedroz on Sat Mar 04, 2006 7:20 pm, edited 1 time in total.
if you're checking to see if a message has already been entered, you should check for an id, or another unique field name
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
d11wtq isn't really a mod........ he just acts like it
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
I don't think your idea of preventing double posts is a good idea, considering there are several valid reasons for multiple posts to be identical.
Example:
Noob: Is this correct? echo 'foobar'; ??
Jcart: Yes
Noob: What about this? ..
Jcart: Yes
Obviously simplified example, but this seems more like an annoiyance for your users than it is helpful in preventing double posts. Instead what you can try it do not allow them to post within 15 (?) seconds of their previous post, eliminating the possiblity of them clicking the submit button twice.
scrotaye wrote:d11wtq isn't really a mod........ he just acts like it
doesnt d11wtq run the site?
Jcart wrote:I don't think your idea of preventing double posts is a good idea, considering there are several valid reasons for multiple posts to be identical.
Example:
Noob: Is this correct? echo 'foobar'; ??
Jcart: Yes
Noob: What about this? ..
Jcart: Yes
Obviously simplified example, but this seems more like an annoiyance for your users than it is helpful in preventing double posts. Instead what you can try it do not allow them to post within 15 (?) seconds of their previous post, eliminating the possiblity of them clicking the submit button twice.
Can you also store the ip of the poster in the same database and then do a check to see if the ip of th eprevious poster matches the ip of the current poster?
Last edited by a94060 on Sat Mar 04, 2006 8:53 pm, edited 3 times in total.
he's actually on topic (answering the question) like we should be
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Can you also store the ip of the poster in the same database and then do a check to see if the ip of th eprevious poster matches the ip of the current poster?
IP's can be disguised easily (proxy), therefor a users IP can never be trusted. There are also legitamate reasons for a users IP to change several times throughout the visit though (AOL users, etc)..
No single person runs the site, every member here runs the site. The mods vote on important issues though.
What I would recommend is storing a md5 hash of the message in the database, and then checking if the md5 hash of the current message matches any other message. This will knock out exact dupes but you still have that 10% difference and the issue that jcart brought up. Could you tell us how this is going to be used because there are different algorithms for example soundex that could be used here..