-1

I don't understand where the problem with my code. Code showing me error message

PHP Parse error: syntax error, unexpected ')' in /home/masudtoo/public_html/autocreate/index.php on line 151

The problem is coming from this code on line 151:

 $google_meta_regex = '/\\<meta http-equiv.+?refresh.+?(http:\\/\\/[^\\'^\\"^\\>]+?)('){0,1}(\\"){0,1}\\>/i';

Full code:

if ( strpos($page, '<meta http-equiv') ) {
    // Follow the Meta redirect
    $google_meta_regex = '/\\<meta http-equiv.+?refresh.+?(http:\\/\\/[^\\'^\\"^\\>]+?)('){0,1}(\\"){0,1}\\>/i';
    preg_match($google_meta_regex,$page,$m);
    $curl_url = $m[1];
    $curl_url = str_replace('&amp;', '&', $curl_url);

    $headers[] = "Cookie: X=abc; GoogleAccountsLocale_session=en; TZ=-330";
    $headers[] = "Content-Type: application/x-www-form-urlencoded";
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

        curl_setopt($ch, CURLOPT_URL, $curl_url);
    curl_setopt($ch, CURLOPT_POST, 0);
        $page = curl_exec($ch);
}

curl_close($ch);
halfer
  • 19,824
  • 17
  • 99
  • 186
  • [Use a real parser, not regex, for this](http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php) – Quentin Feb 24 '17 at 08:52

1 Answers1

0

The issue was, you forgot to escape one quote ' that was conflicting with one of the closing qoutes of the string. So, the following regex / code should work :

$google_meta_regex = '/\\<meta\\shttp-equiv.+?refresh.+?(http\\:\\/\\/[^\\\'^\\"^\\>]+?)(\\\'){0,1}(\\"){0,1}\\>/i';
m87
  • 4,445
  • 3
  • 16
  • 31