• Techamaki

  • Deleting Spam From Your Web Site Database

13th June 2007

Deleting Spam From Your Web Site Database

posted in SQL, Spam |

In 2002 I developed a hobby site (www.coolslang.com) to learn PHP, MySQL, Unicode and CSS-P (CSS Positional). I hadn’t looked at the site for years. But when I did visit recently, I was surprised, that not only was the site still running but that I had 7000 comments in the commenting system!

Were all these comments because my site had become insanely popular during my absence?  No, unfortunately it was from spam. The usual commenter told me not only how great my site was, but that if I needed some Viagra, this is a link to find it.

How do all these people know that I suffer from ED! I must check again for those hidden cameras in the bedroom. Now, not only did I have a limp dick but also a bloated database. What to do?

Going through 7000 records one-by-one would, of course, be out of the question. But then all of the spam contain hyperlinks to their web sites. So the solution is to delete all the comments with “http://”. First I selected these spam comment records using the following statement to verify that this is indeed what I really wanted:

SELECT * FROM comments WHERE comment-text RLIKE ‘http://’

Then simply substitute “DELETE” for the “SELECT *”

DELETE FROM comments WHERE comment-text RLIKE ‘http://’

Problem solved, well at least one of them…

This entry was posted on Wednesday, June 13th, 2007 at 4:22 pm and is filed under SQL, Spam. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

There is currently one response to “Deleting Spam From Your Web Site Database”

Why not let us know what you think by adding your own comment! Your opinion is as valid as anyone elses, so come on... let us know what you think.

  1. 1 On July 12th, 2008, jchap said:

    Nice idea to clean up SQL database entries on the server side! This will, of course, delete everything with the “http://” text in there… ah well, if you’re desperate, you’re desperate.

Leave a Reply

  • Calendar

  • September 2010
    M T W T F S S
    « Jun    
     12345
    6789101112
    13141516171819
    20212223242526
    27282930