...

View Full Version : Preg_Match / Regex Trouble



Jesuspwnt
12-27-2007, 08:08 PM
whats wrong with this script?

Its for a friend of mine who wants to get the top 5 "featured" links from that site( near the bottom)

all i get is an error :
Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 48

Code:


<?php
set_time_limit(0);
ob_implicit_flush();
ignore_user_abort(1);
function open_page($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_REFERER, "http://www.myspace.com");
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded"));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$page = curl_exec($ch);
curl_close($ch);
return $page;
}
$body = open_page("http://www.leisuredirection.co.uk/THEINDEPENDENT/HOD/CIT");
$body = explode(" <td class=\"HOD_T_OF_Title\">Our Featured\r\n Short City Break Holidays\r\n Selection<br>", $body);
$body = explode("<iframe width=98&#37; height=\"327\" marginwidth=0 frameborder=0 scrolling=no id=ifr_SBP name=ifr_SBP", $body[1]);
$body = $body[0];
preg_match("/ <td class=\"HOD_T_OF_Loc\">\r\n <a href='(*.?)'>\r\n (*.?)\r\n <\/a>\r\n <\/td>/", $body, $links);
unset($links[0]);
//Links are located in $links[1-5]
$i = 0;
while($i <= 5){
echo $link;
$i++;
}
?>

Thanks in advance

Mwnciau
12-27-2007, 09:45 PM
Your second (.*?) is misstyped, (*.?)

Jesuspwnt
12-27-2007, 11:52 PM
Thanks, now i just created another script but im getting this error:
Warning: preg_match() [function.preg-match]: Unknown modifier 'b' in [path]/public_html/[file].php on line 61

code:

preg_match("/<tr><td align=\"right\"><b>Address&nbsp;</b><\/td><td>(.*?)&nbsp;<\/td><\/tr>/", $page, $address);


any ideas? :S

oesxyl
12-28-2007, 12:01 AM
Thanks, now i just created another script but im getting this error:
Warning: preg_match() [function.preg-match]: Unknown modifier 'b' in [path]/public_html/[file].php on line 61

code:

preg_match("/<tr><td align=\"right\"><b>Address&nbsp;</b><\/td><td>(.*?)&nbsp;<\/td><\/tr>/", $page, $address);


any ideas? :S


preg_match("/<tr><td align=\"right\"><b>Address&nbsp;<\/b><\/td><td>(.*?)&nbsp;<\/td><\/tr>/", $page, $address);

\ before /b>

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum