开发者

PHP "require_once" says it can't find a file in the directory

开发者 https://www.devze.com 2022-12-18 00:19 出处:网络
I\'m debugging some PHP code written by an outsourcing company (I\'m not a PHP guy at all but know the basics; we have an offshore team of PHP developers working for us on this project) that\'s not wo

I'm debugging some PHP code written by an outsourcing company (I'm not a PHP guy at all but know the basics; we have an offshore team of PHP developers working for us on this project) that's not working; the code is supposed to be called every 30 minutes by a cron job but its not firing. I tried to run the PHP script via the command l开发者_运维百科ine to test if it's working, but it's giving me the following (anonymized) errror:

PHP Fatal error: require_once(): Failed opening required '/myapp/_lib/_classes/MySql.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/myapp/_lib/_base/common.inc.php on line 6

However, the file /var/www/html/myapp/_lib/_classes/MySql.php exists under the proper directory. I'm missing something simple, I'm sure, but like I said I know really nothing beyond the bare basics of PHP and I really need to get this service up and running.

EDIT: The code is using the __autoload() function with all classes in /_lib/_classes


if you start a file name with a slash, it means it's an absolute path. try instead:

require_once('/var/www/html/myapp/_lib/_classes/MySql.php');


Case sensitivity maybe? I've had that problem before.


I'm guessing it's a permissions issue - make sure both your account (for testing purposes) and whatever account cron is going to run your script under (quite possibly yours, but maybe a different one) have read privileges on the file.

Also: the path for the include says /myapp/_lib/_classes/MySql.php, whereas it exists in /var/www/html/myapp/_lib/_classes/MySql.php. Can you change the include to reference the full path?


As said, casing and in addition the correct permissions to access that file are needed.

0

精彩评论

暂无评论...
验证码 换一张
取 消