dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTIO

Hybrid View

  1. #1
    Join Date
    Apr 2013
    Posts
    3

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTIO

    Hello

    When I run this command-bash-3.2 $ php magmi.cli.php-mode = update-profile = default SSH to import a csv file Magento products in my shop I get this message:

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/content/17/10622317/html/magmi/inc/magmi_loggers.php on line 4
    PHP Code:
    <?php 
    class FileLogger
    {
    protected 
    $_fname;

    public function 
    __construct($fname=null)
    {
    if(
    $fname==null)
    {
    $fname=Magmi_StateManager::getProgressFile(true);
    }
    $this->_fname=$fname;
    $f=fopen($this->_fname,"w");
    if(
    $f==false)
    {
    throw new 
    Exception("CANNOT WRITE PROGRESS FILE ");
    }
    fclose($f);
    }

    public function 
    log($data,$type)
    {

    $f=fopen($this->_fname,"a");
    if(
    $f==false)
    {
    throw new 
    Exception("CANNOT WRITE PROGRESS FILE ");
    }
    $data=preg_replace ("/(\r|\n|\r\n)/""<br>"$data);
    fwrite($f,"$type:$data\n");
    fclose($f);
    }

    }

    class 
    EchoLogger
    {
    public function 
    log($data,$type)
    {
    $info=explode(";",$type);
    $type=$info[0];
    echo(
    '<p class="logentry log_'.$type.'">'.$data."</p>");
    }

    }
    class 
    CLILogger
    {
    public function 
    log($data,$type)
    {
    echo(
    "$type:$data\n");
    }
    }
    ?>
    Last edited by NogDog; 04-18-2013 at 03:28 PM. Reason: added [php] tags

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    21,309
    Sounds like your command line version of PHP is running PHP 4.x, but your script is using PHP 5.x syntax (e.g. the "public" keywords).
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Apr 2013
    Posts
    3
    I am using php 5.3 on my server

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    21,309
    Try this from the same command line where the script fails:

    Code:
    php -r "echo phpversion().PHP_EOL;"
    At worst, it proves I'm wrong.

    Some web servers have both 4 and 5 installed, with the web server accessing one by default and the other with a different file suffix (e.g. foo.php4), one version running as a SAPI module and one as CGI. It's possible that the shell path for the command line interface is pointing to the PHP 4 version of the PHP executable.
    Last edited by NogDog; 04-18-2013 at 03:56 PM.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    21,309
    PS, if that's the case, you might need to use the full path to the desired PHP version:
    Code:
    /path/to/php_5.3.2/php your_file.php
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles