Preg and Sql

Status
Not open for further replies.

Chris2k

Banned
Banned
901
2009
17
0
Hi,

here's my code:

PHP:
		$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 ."'");

?
 
6 comments
Error is on the sql query:
PHP:
mysql_query("DELETE FROM wcddl_sites WHERE url='". $naD ."'");
Deleting a field from mysql where url is regex :|
PHP:
mysql_query("DELETE FROM wcddl_sites WHERE url='". $surl ."'");

And yes, you can use mysql REGEXP query to directly delete without checking with preg_match but then it will delete all the matching urls in the table, not only the url one.
 
Error is on the sql query:
PHP:
mysql_query("DELETE FROM wcddl_sites WHERE url='". $naD ."'");
Deleting a field from mysql where url is regex :|
PHP:
mysql_query("DELETE FROM wcddl_sites WHERE url='". $surl ."'");

And yes, you can use mysql REGEXP query to directly delete without checking with preg_match but then it will delete all the matching urls in the table, not only the url one.

tried this at the start:
PHP:
mysql_query("DELETE FROM wcddl_sites WHERE url='". $surl ."'");

^^ no luck. your 2nd point is what im tryna do, ddelete all the urls, do u no the correct syntax for?
 
Then there must be something wrong with the regex then, your syntax is correct for other query

Paste a test url that you are trying to match and delete from table ($surl) here

As from checking your regex a little, it matches the urls that has free domain: http://asd.mysiteproject.com -- matches
 
Code:
*snip*|zoomshare\.com|webblogg\.se|tl|se|de|edu)@i
you need a subgroup

Code:
*snip*|zoomshare\.com|(webblogg\.se|tl|se|de|edu))@i
 
Status
Not open for further replies.
Back
Top