Operation not permitted for include_once

Website URL

loco81.ir

Error Message

Warning : include_once(): open_basedir restriction in effect. File(/config/config.php) is not within the allowed path(s): (/php_sessions:/tmp:…:/var/www/errors:/home/vol10_1/infinityfree.com//.com/htdocs) in /home/vol10_1/infinityfree.com//loco81.ir/htdocs/index.php** on line 3

Warning : include_once(/config/config.php): Failed to open stream: Operation not permitted in /home/vol10_1/infinityfree.com/ /loco81.ir/htdocs/index.php* on line 3

Warning : include_once(): Failed opening ‘/config/config.php’ for inclusion (include_path=‘.:/usr/share/pear/’) in /home/vol10_1/infinityfree.com/ /loco81.ir/htdocs/index.php* on line 3

Other Information

Hi, how to fix that? (error in line that includes my database info on my code) other similar topics could not help me.
i have just this domain and don’t have sub domains or…
and don’t have .htaccess file
whats the problem?

looks like the path may be wrong in the “include_once” statement.

but without seeing the php I can’t be 100% sure

4 Likes

This path is not correct. When you specify a path with a slash at the start, it becomes an absolute path, meaning it is loaded relative to the root of the file system (essentially the server’s C:\ drive), not relative to your website directory.

You’ll probably want to change the path /config/config.php to config/config.php, so the file is loaded to a path relative to the directory you’re loading executing the include statement in.

6 Likes

include_once DIR . ‘/config/config.php’; fixed it.
thanks a lot

1 Like

fixed.

Yep, that works too! Specifying an absolute path works, you just need to make sure you correctly prefix the include path with the current directory.

7 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.