...

View Full Version : Preg and Sql



Chris-2k
04-22-2012, 01:34 AM
Hi,

here's my 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 ."'");

?

Dormilich
04-22-2012, 10:55 AM
what happens if you try it?

Chris-2k
04-22-2012, 10:54 PM
tried:



$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.

Lamped
04-23-2012, 02:46 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum