Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

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

share|improve this question
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. – Amal Murali Dec 21 '13 at 19:56
    
On my hosting settings PHP is set to 5 but whith SSH it shows me 4.4.9 – user3125921 Dec 21 '13 at 20:20
3  
Then ask your hosting provider to upgrade the CLI version of PHP to match the Webserver version – Mark Baker Dec 21 '13 at 21:02
    
I had to run my script with this: php5.4 script.php > Thanks, worked for me! – Anna Völkl Feb 10 '14 at 14:50

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.