SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Non-Member
    Join Date
    Mar 2004
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parse error: syntax error, unexpected T_STRING

    Reading the "important" posts at the top of this PHP forum, I can tell that there is supposed to be a missing quote, or parentheses on line four or five, but I can't simply figure out where.

    Some help is appreciated.

    The error, I get is: Parse error: syntax error, unexpected T_STRING in C:\wamp\www\mydomain\logs.php on line 5

    Code:
    <?php
    // Getting the information
    $ipaddress = $_SERVER['REMOTE_ADDR'];
    $page = "http\://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";
    $page .= iif(!empty($_SERVER['QUERY_STRING']), '?($_SERVER['QUERY_STRING'])',"");
    $referrer = $_SERVER['HTTP_REFERER'];
    $datetime = mktime();
    $useragent = $_SERVER['HTTP_USER_AGENT'];
    $remotehost = @getHostByAddr($ipaddress);
    // Create log line
    $logline = $ipaddress . "|" . $referrer . "|" . $datetime . "|" . $useragent . "|" . $remotehost . "|" . $page . "\n";
    
    // Write to log file:
    $logfile = "c:/wamp/www/mydomain/logfile.txt";
    
    // Open the log file in “Append” mode
    if (!$handle = fopen($logfile, 'a+')) {
    die("Failed to open log file");
    }
    
    // Write $logline to our logfile.
    if (fwrite($handle, $logline) === FALSE) {
    die("Failed to write to log file");
    }
    
    fclose($handle);
    ?>
    Thanks in advance.

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Code PHP:
    $page .= iif(!empty($_SERVER['QUERY_STRING']), "?{$_SERVER['QUERY_STRING']}","");
    The only code I hate more than my own is everyone else's.

  3. #3
    ¬.¬ shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    $page .= iif(!empty($_SERVER['QUERY_STRING']), '?($_SERVER['QUERY_STRING'])',"");

    What in the world are you doing here?
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    I didn't want to be the one to pass judgement but since it was brought up and all…

    The iif function looks to me like an abstraction of the ternary operator. If so I can't say I would agree with having a function for that…
    The only code I hate more than my own is everyone else's.


Bookmarks

Posting Permissions

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