0
votes

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? - IOrlandoni
set display_errors to on in your php.ini. Maybe the file is not included? - Maxim Krizhanovsky
@OhCaN - closing php tags aren't needed for .php files as long as there is no non-php code after it. - Jake Wilson
@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. - Jake Wilson

4 Answers

4
votes

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.

2
votes

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

1
votes

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