"leegold2" <le******@verizon.net> wrote in message
news:wz******************@nwrddc01.gnilink.net...
I'm new to PHP regex. What I am trying to match is:
http://library.dayton.town.net
it's a mysql/php field.
Then if a match I take some action.
But it's not working any help appreciated. Thanks
while ( $row = mysql_fetch_row( $result ) ) {...
....
foreach($row as $data) {
if ( preg_match ( "/http://library\.dayton\.town\.net/", $data ) )
$data= 'You got a match';
....
Without looking too closely or trying it, the // after http: are likely
being translated as pattern terminators. Escape them ("leaning toothpick"
syndrome ahoy), or change the terminators from / to something else like ?.
Escape anything that isn't alphanumeric for safety, too (the : character).
$pattern="?http\://library\.dayton\.town\.net?";
or
$pattern="/http\:\/\/library\.dayton\.town\.net/";
Then
if ( preg_match ( $pattern, $data ) )
Etc.
Of course, in this case you could always use
if($data == "http://library.dayton.town.net")
........
lol
Garp