0

I'm running a simple CentOS 5.5 server with PHP 5.2.10. I'm trying to use PHP Simple HTML Dom parser but I get a 500 Server Error. Here is the script:

<?php
include_once('simple_html_dom.php');
$html = file_get_html('http://www.google.com/');

As you can see, I'm not even doing anything with the parser yet except trying to open a url. And that file_get_html is resulting in a 500 Server Error.

I don't see any errors showing up in the httpd error log. So I'm not sure where to look to figure out the problem. The only PHP requirements for Simple HTML Dom parser seem to be PHP 5+ (check) and php allow_url_fopen = On (check).

4
  • there is a closing tag there, right? Commented Aug 31, 2011 at 17:42
  • 1
    set display_errors to on in your php.ini. Maybe the file is not included? Commented Aug 31, 2011 at 17:44
  • 1
    @OhCaN - closing php tags aren't needed for .php files as long as there is no non-php code after it. Commented Aug 31, 2011 at 20:33
  • @Darhazer - You had the right approach. Mine was set to Off. Give a proper answer below and I'll be sure to give you credit. Commented Aug 31, 2011 at 20:37

4 Answers 4

4

Since version 5.2, PHP will generate HTTP 500 response if there is fatal error, and display_errors is off. Turn in on to see the error, that stops the execution of the script. Maybe file is not included (wrong permissions, path) and file_get_html() is not defined, or maybe file_get_html() produces a fatal error.

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

Comments

2

try this file_get_contents

Comments

2

maybe it's because the "php-mbstring" module did not installed ? you could using ini_set('display_errors', 'On'); to check this out .

Comments

1

Per Vitor's suggestion, I changed solved this problem by changing file_get_html to file_get_contents. Since I wanted to use the 'find' feature in simple_html_dom, I had to then convert the string to an object:

$string = file_get_contents(http://thedeadfallproject.com/)
$object = new simple_html_dom();
$object->load($string); // Load HTML from a string

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.