Results 1 to 10 of 10
  1. #1
    Analytics Dude Kevin's Avatar
    Join Date
    January 18th, 2005
    Location
    Rochester, NY
    Posts
    5,904
    PHP Question... Must be over tired
    Can someone have a look at this and tell me why I'm getting

    Parse error: syntax error, unexpected '{' in /home/*****/public_html/*****/****/LogParser.php on line 52

    Code:
     
    <?php
    $ac_arr = file('/home/*****/public_html/****/****/*****');
    $astring = join("", $ac_arr);
    $astring = preg_replace("/(\n|\r|\t)/", "", $astring);
    $records = preg_split("/([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $astring, -1, PREG_SPLIT_DELIM_CAPTURE);
    $sizerecs = sizeof($records); 
    // now split into records
    $i = 1;
    $each_rec = 0;
    $new_format[$each_rec] = "$ip\t$access_time\t$link[0]\t$link[1]\t$success_code\t$bytes\t$ref\t$browser";
    while($i<$sizerecs) {
    $ip = $records[$i];
    $all = $records[$i+1];
    // parse other fields
    preg_match("/\[(.+)\]/", $all, $match);
    $access_time = $match[1];
    $all = str_replace($match[1], "", $all);
    preg_match("/\"GET (.[^\"]+)/", $all, $match);
    $http = $match[1];
    $link = explode(" ", $http);
    $all = str_replace("\"GET $match[1]\"", "", $all);
    preg_match("/([0-9]{3})/", $all, $match);
    $success_code = $match[1];
    $all = str_replace($match[1], "", $all);
    preg_match("/\"(.[^\"]+)/", $all, $match);
    $ref = $match[1];
    $all = str_replace("\"$match[1]\"", "", $all);
    preg_match("/\"(.[^\"]+)/", $all, $match);
    $browser = $match[1];
    $all = str_replace("\"$match[1]\"", "", $all);
    preg_match("/([0-9]+\b)/", $all, $match);
    $bytes = $match[1];
    $all = str_replace($match[1], "", $all);
    print("<br>IP: $ip<br>Access Time: $access_time<br>Page: $link[0]
    	<br>Type: $link[1]<br>Success Code: $success_code
    	<br>Bytes Transferred: $bytes<br>Referer: $ref
    	<br>Browser: $browser<hr>");
    // advance to next record
    $i = $i + 2;
    $each_rec++;
    }
    $fhandle = fopen("/home/******/public_html/****/****/***tabs.txt", "w") 
    {
    foreach($new_format as $data) {
    	 fputs($fhandle, "$data\n");
    }
    fclose($fhandle);
    }
    ?>
    Kevin Webster
    twitter: levelanalytics

    Kayak Fishing
    Web Analytics and Affiliate Marketing

  2. #2
    ...and a Pirate's heart. Convergence's Avatar
    Join Date
    June 24th, 2005
    Posts
    6,918
    Can you re-paste the above with line numbers? I put it into my text editor and only got 49 lines.
    Salty kisses, Sandy toes, and a Pirate's heart...

  3. #3
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Which one is line 52?

    Is this a problem (dbl quotes around a variable name)? fputs($fhandle, "$data\n");

  4. #4
    Analytics Dude Kevin's Avatar
    Join Date
    January 18th, 2005
    Location
    Rochester, NY
    Posts
    5,904
    The error appears to be in here, with the first line being 52:


    Code:
     
    $fhandle = fopen("/home/******/public_html/****/****/***tabs.txt", "w") 
    {
    foreach($new_format as $data) {
    fputs($fhandle, "$data\n");
    }
    fclose($fhandle);
    }
    ?>
    Kevin Webster
    twitter: levelanalytics

    Kayak Fishing
    Web Analytics and Affiliate Marketing

  5. #5
    Analytics Dude Kevin's Avatar
    Join Date
    January 18th, 2005
    Location
    Rochester, NY
    Posts
    5,904
    Actually, the way I printed it here, the error generates on 53, which is the standalone {
    Kevin Webster
    twitter: levelanalytics

    Kayak Fishing
    Web Analytics and Affiliate Marketing

  6. #6
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    What is the opening bracket on line 53 for?

  7. #7
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Oh, you missing a semi-colon at the end of your fopen.

  8. #8
    Analytics Dude Kevin's Avatar
    Join Date
    January 18th, 2005
    Location
    Rochester, NY
    Posts
    5,904
    Ah! After "w") ?
    Kevin Webster
    twitter: levelanalytics

    Kayak Fishing
    Web Analytics and Affiliate Marketing

  9. #9
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    Quote Originally Posted by Kevin
    Ah! After "w") ?
    Yes

  10. #10
    Analytics Dude Kevin's Avatar
    Join Date
    January 18th, 2005
    Location
    Rochester, NY
    Posts
    5,904
    Got it, thanks. Now just working on the writing permissions.
    Kevin Webster
    twitter: levelanalytics

    Kayak Fishing
    Web Analytics and Affiliate Marketing

  11. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. PHP question - include(file.php) with variables
    By teezone in forum Programming / Datafeeds / Tools
    Replies: 8
    Last Post: September 4th, 2009, 04:54 PM
  2. Php question
    By zimmy in forum Programming / Datafeeds / Tools
    Replies: 7
    Last Post: September 16th, 2006, 10:26 PM
  3. Help Please - .php Question
    By ~Michelle in forum Programming / Datafeeds / Tools
    Replies: 12
    Last Post: March 18th, 2004, 02:52 PM

Posting Permissions

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