Jump to content

No such file or directory


The Little Guy

Recommended Posts

Why does this code:

require_once "../../media/php/classes/Mysql.inc.php";

 

Work when I go to:

http://mysite.com/API/v1/index.php

 

But when I go to:

http://mysite.com/index.php

 

it doesn't work.

 

The require is being called from another class, which I call from the two pages above. The class loads, but in the second link, I get failed to open stream: No such file or directory but the first one works fine. What would cause this?

 

could this be an htaccess thing?

 

htaccess:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php [L,QSA]

Link to comment
https://forums.phpfreaks.com/topic/253446-no-such-file-or-directory/
Share on other sites

Why does this code:

require_once "../../media/php/classes/Mysql.inc.php";

 

Work when I go to:

http://mysite.com/API/v1/index.php

 

But when I go to:

http://mysite.com/index.php

 

it doesn't work.

 

Because ../../media/php/classes/Mysql.inc.php quote obviously doesn't exist when called from your sites root.

shouldn't it be calling it from the location of the file that has the require?

 

I am including:

"API/v1/class/Main.php"

 

Within that file I am including:

"../../media/php/classes/Mysql.inc.php"

 

shouldn't it be up two directories from where "Main.php" is, and not the current running file?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.