1

I wrote a php script that use simple_html_dom to parse a website infos. Its a big script and when I try to run it on my browser the script works but Time out before to end.. When I try using SSH I get this error:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in .... on line 30

line 30:

$titlevar = explode('for €', $element->find('a[class="title-link"]', 0)->plaintext);

Whats wrong with my code ? PS: I thought it was a problem with my php version so I tried to rename my file to .php5 but still not working... I changed my .htaccess to enable php5 but still when I use php -v it shows me PHP 4.4.9.

EDIT:

I had to run my script with this:

php5.4 script.php

4
  • 2
    Why are you still using an ancient PHP version? PHP 4.4.9 was released almost 5 years ago. You should upgrade your PHP version. Commented Dec 21, 2013 at 19:56
  • On my hosting settings PHP is set to 5 but whith SSH it shows me 4.4.9 Commented Dec 21, 2013 at 20:20
  • 3
    Then ask your hosting provider to upgrade the CLI version of PHP to match the Webserver version Commented Dec 21, 2013 at 21:02
  • I had to run my script with this: php5.4 script.php > Thanks, worked for me! Commented Feb 10, 2014 at 14:50

2 Answers 2

0

If you're unable to access CLI php with a modern version, you can execute the script through the webserver by using something like wget to run it through the webserver. Might want to set it up to run through localhost in that case.

Sign up to request clarification or add additional context in comments.

Comments

0

PHP4 doesn't allow method chaining which you're doing with $element->find('a[class="title-link"]', 0)->plaintext.

Also, simple_html_dom requires PHP5 so even if you fix the syntax error you'll still get function or class does not exist errors after.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.