I have __autoload() function and it works fine on localhost but causes error on server:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@mudre-izreke.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I really dont know what I'm doing wrong :S
Here is autoload() function:

function __autoload($className) {
	// search util class
	if(file_exists(F_DIR.'lib/util/'.$className.'.class.php')) {
		// include file
		require_once(F_DIR.'lib/util/'.$className.'.class.php');
		return;
	}
}

I tried it on my server an 2 free hosts and it doesnt work.. but on localhost it works :S

    You need to find where F_DIR is defined. It's probably in a file called config.php and probably looks something like this:

    define('F_DIR', '/path/to/some/location/');

    this will have to be changed to reflect the location of the files on your server.

      What is the evidence that the __autoload() is causing that error?

        F_DIR is defined in framework directory.

        define('F_DIR', dirname(__FILE__).'/');

        Why to change this? if for example i change path in autoload function to some which doesnt exists than application "works" and shows error.. e.g 'class UserUtil doesnt exists'.. but if path is correct than it shows internal error :S

        @, if i delete __autoload() function than there is no 'internal server error'..

        I tried to change path in __autoload(), tried absolute and relative path, but both doesnt work.. I tried to write autoload in index.php. I even try some path that doesnt exists, if that is the case than it doesnt show server error but expected php error (see previous example).

        Do you know why this (internal server error) occurs, what can cause it, and what would you check..?

        Thanks, I really cant think of anithing else...

          I think I was mistaken. had assumed that F_DIR would be defined as a static value but this definition looks like it would change to a legit value even if you moved to a new server.

          NogDog is right to be asking why you are sure. Do you know what version of PHP you are running? If you read the docs on [man]autoload[/man] then you'll see that it has notes about being available since php5, etc.

          Have you tried checking the PHP error log?

            It just seems weird to me that an autoload would cause that sort of server error to be generated -- I would expect at worst to see a PHP error message saying it could not find/read the file it was trying to include. However, if this is part of a framework, it might be doing its own weird things in terms of error-trapping, I suppose. The suggestion to check your PHP error log may be a good one to see if there's more info about the actual root cause of the problem.

              I'm starting to think this problem is due to a difference in web server configurations between your server and localhost. I've had problems like that most often with things like mod_rewrite rules in an .htaccess file, for instance.

                16 days later

                I structured my files in framework more logicaly and now autoload works like it should.. But there is still this internal server error :S
                I manage to find what causing it.. When file config.inc.php exists and contains valid data to connect to database than script works perfectly, but when that file doesnt exists (before instalation) than this error occurs.

                This is function called by my mysql __construct() class:

                	protected function connect() {
                		$this->linkID = @mysql_connect($this->host, $this->user, $this->password);
                
                	if ($this->linkID === false) {
                		$this->error("Link-ID == false, connect failed");
                	}
                
                	if (!empty($this->charset)) {
                		$this->setCharset($this->charset);
                	}
                }

                If i change data in script itself and i enter correct data (e.g. i replace $this->host with 'mysqlHost') it works.. but if i enter wrong data than internal error is displayed.. Why is this code ignored?:

                ...
                		if ($this->linkID === false) {
                			$this->error("Link-ID == false, connect failed");
                		}
                ...

                  The code may not be ignored. The code that uses this class may not respond properly to the error event.

                    Write a Reply...