简体   繁体   中英

PHP Fatal error: Call to undefined method after uploading on the web

I have some pages, which work fine locally(using WAMP and error_reporting E_ALL in php.ini), but once I upload them, I get the following error: Fatal error: Call to undefined method DB::exists() The method is there, and I don't know why it can't be seen.

Do you have an idea what went wrong?

Try putting a debug statement into the file that defines class DB and DB::exists() , such as:

echo "DB file was included\n";

Does that message appear? If not, then the file isn't being included, which explains why the method isn't found.

Find the the location where that file is supposed to be getting included, and examine the include path at the point:

echo "Include path is: " . get_include_path() . "\n";

Does another file with the same name exist in one of the other directories listed in the include path? If so, you might need to alter the other of the entries in your include path (which is defined by include_path in php.ini, but can also be edited at runtime with set_include_path() )

No, the method isn't there. The sooner you learn to trust to the error messages, the sooner you get your application to work.

You have probably installed pear and some libraries in other place than your website code. Check where points you includes in php.ini and upload that too.

You probably want to check the webserver's php.ini configuration against your local php.ini to see if there is any modules not loaded on the webserver which may be required in your PHP application.

Also, check the version numbers of PHP on your webserver and local PHP as well as checking up the web for limitations of your PHP version.

The server has Pear::DB installed ( http://pear.php.net/package/DB/redirected ). Your autoload function is loading Pear's DB class instead of yours.

If you have control over the server, something like this should work

$ sudo pear uninstall DB

If you don't have control over the server, you'll need to rename your DB class to something else...

You could modify the include_path to load PEAR classes after your own classes, but that could lead to other naming conflicts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM