Siva G
Siva G

Reputation: 1174

500 internal sever error While referring a file in PHP?

I am facing a problem 500 internal server error while referring a file through PHP

Here is my code

<?php
require_once(dirname(__FILE__).'/html2pdf.class.php');
?>

Here I am having the class file in the same folder itself...

Upvotes: 0

Views: 1530

Answers (2)

antoox
antoox

Reputation: 1319

In your php.ini :

  • if you want an output of the errors : set display_errors to On
  • if you want to see the errors in your log file : set the log_errors to On and the error_log to a string file path (exemple: error_log = /var/log/php-scripts.log)

You could find the different parameters of php.ini runtime configuration here.

After the restart of your web server, if you fall into an unexpected 500 error; it may be because of the "@" operator: from the documentation:

Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why.

And nothing to do but in php5.3 you can do: ( __DIR__ instead of dirname(__FILE__) )

<?php
require_once(__DIR__.'/html2pdf.class.php');
?>

Upvotes: 1

Borniet
Borniet

Reputation: 3546

Check the ownership and group for the files giving the error, and the accessrights of the directory they are in. Most probably your webserver cannot access these files. You can change the ownership using:

chown username:groupname filename

where username is the webservers username, and groupname is the webserver's groupname.

Upvotes: 1

Related Questions