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
  1. #1
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Preg_Match / Regex Trouble

    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 Code:
    <?php
    set_time_limit
    (0);
    ob_implicit_flush();
    ignore_user_abort(1);
    function 
    open_page($url){
     
    $ch curl_init();
     
    curl_setopt($chCURLOPT_COOKIEJAR"cookie.txt");
     
    curl_setopt($chCURLOPT_COOKIEFILE"cookie.txt");
     
    curl_setopt($chCURLOPT_REFERER"http://www.myspace.com");
     
    curl_setopt($chCURLOPT_USERAGENT$_SERVER['HTTP_USER_AGENT']);
     
    curl_setopt($chCURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded"));
     
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
     
    curl_setopt($chCURLOPT_SSL_VERIFYHOST1);
     
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
     
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
     
    curl_setopt($chCURLOPT_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% 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

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    Your second (.*?) is misstyped, (*.?)

  • #3
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    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:
    PHP Code:
    preg_match("/<tr><td align=\"right\"><b>Address&nbsp;</b><\/td><td>(.*?)&nbsp;<\/td><\/tr>/"$page$address); 

    any ideas? :S

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Jesuspwnt View Post
    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:
    PHP Code:
    preg_match("/<tr><td align=\"right\"><b>Address&nbsp;</b><\/td><td>(.*?)&nbsp;<\/td><\/tr>/"$page$address); 

    any ideas? :S
    PHP Code:
    preg_match("/<tr><td align=\"right\"><b>Address&nbsp;<\/b><\/td><td>(.*?)&nbsp;<\/td><\/tr>/"$page$address); 
    \ before /b>

    best regards

  • Users who have thanked oesxyl for this post:

    Jesuspwnt (12-28-2007)


  •  

    Posting Permissions

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