Search code examples
phpparse-error

Parse error: syntax error, unexpected T_STRING in line


When I trying to run a file using cron jobs I am getting the following

Parse error: syntax error, unexpected T_STRING in /home/joshand2/public_html/application/models/model_posting.php on line 1787

The line in 1787 is goto endofloop; I don't know if there is any syntax related issue in this line or not but the endofloop refers to.

endofloop:

if (file_exists("cookies/".$this->job_id."_job_".$this->site_id."_site.txt")) {
    echo "The file cookies/".$this->job_id."_job_".$this->site_id."_site.txt exists"; 
    unlink("cookies/".$this->job_id."_job_".$this->site_id."_site.txt");
}

Can anybody help me in fixing this error?


Solution

  • You likely need to re-factor your code to avoid using goto jump labels.

    Because:

    1. It sounds as if your PHP version may not support it yet (Version <5.3 as suggested by DaveRandom)
    2. There is probably a way to avoid the jump labels and still achieve the same behavour