Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Preg and Sql

  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts

    Preg and Sql

    Hi,

    here's my code:

    PHP Code:
            $naD '@^(?:http:\/\/)?([^/]+)\.(mysiteproject\.com|qualtrics\.com|doattend\.com|ning\.com|eventzilla\.net|page\.tl|weebly\.com|espacioblog\.com|pbworks\.com|mysoulspot\.com|fora\.se|healthkicker\.com|posterous\.com|springnote\.com|renspace\.com|beep\.com|blog4ever\.com|insanejournal\.com|webs\.com|zoomshare\.com|webblogg\.se|tl|se|de|edu)@i';

            if(
    preg_match($naD$surl)) {
                
    mysql_query("DELETE FROM wcddl_sites WHERE url='"$naD ."'");
    //            header("Location: http://www.google.com");
            

    its not working, What im tryna do is filter those urls via $naD,google says i can use:

    mysql_query("DELETE FROM wcddl_sites WHERE url REGEXP '". $naD ."'");

    Can ay1 tell me this ok and if this ok: mysql_query("DELETE FROM wcddl_sites WHERE url REGEXP '". $naD ."'");

    ?

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,472
    Thanks
    13
    Thanked 361 Times in 357 Posts
    what happens if you try it?
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    303
    Thanks
    29
    Thanked 0 Times in 0 Posts
    tried:

    PHP Code:
            $naD '@^(?:http:\/\/)?([^/]+)\.(mysiteproject\.com|qualtrics\.com|doattend\.com|ning\.com|eventzilla\.net|page\.tl|weebly\.com|espacioblog\.com|pbworks\.com|mysoulspot\.com|fora\.se|healthkicker\.com|posterous\.com|springnote\.com|renspace\.com|beep\.com|blog4ever\.com|insanejournal\.com|webs\.com|zoomshare\.com|webblogg\.se|tl|se|de|edu)@i';

            
    mysql_query("DELETE FROM wcddl_blacklist WHERE url REGEXP '"$naD ."'");
            
    mysql_query("DELETE FROM wcddl_sites WHERE url REGEXP '"$naD ."'"); 
    not working.

  • #4
    Super Moderator
    Join Date
    Feb 2009
    Location
    England
    Posts
    539
    Thanks
    8
    Thanked 63 Times in 54 Posts
    MySQL's regular expressions aren't as powerful as PHP's. I suggest building your regex in a query inside phpMyAdmin or some other tool so you know what regex will actually work.
    lamped.co.uk :: Design, Development & Hosting
    marcgray.co.uk :: Technical blog


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •