PHP Fatal error: Could not open window

I have a script called 'sess-start.php' which is in the / include directory in my httpdocs directory.

My site continues this error: \

[Fri Mar 25, 14:52:24 2011] [error] [client 12.3.3.3] PHP Fatal error: require () [function.require]: Unsuccessful opening of '/includes/sess-start.php' (include_path = '.:') in /var/www/vhosts/site.com/httpdocs/page.php on line 4, referent: https://www.site.com/

although www.site.com/includes DOES exist. What gives!

Change 1

They include / require, which themselves may contain additional require or include requests. Relative paths DO NOT WORK, so please do not suggest such.

My .htaccess file already indicates that all include paths to the root directory of the site:

php_value include_path.:/Var/WWW/ virtual domains /site.com/httpdocs

Edit 2

Not all of my included or required scripts are in the same directory, so the suggestion to just put the / include directory in include_path will also be reset (and, in turn, also causes problems on the Windows machine).

Update

Perhaps some explanations on an example in real life can help solve the problem that our team is trying to solve:

On one page, the user can enter several parameters, the next page does the necessary calculations and, based on this, routes the client to several potential parameters, all of which lead to statements about something like a database record.

Then inside the db record (or some other action), if everything goes smoothly, the member may have chosen earlier to receive an email confirmation based on his actions. This request requires in the 2nd requirement (db insert), but is located in a different directory than the second, and thus causes a conflict, since the first file incorrectly refers to the link.

Hard coding the absolute path or even setting the appropriate path to include on the page is “ok”, but then it disables our ability of the command to link between files with Dreamweaver (or any other program that does the same) because it does not recognize "site root" when working in a test environment.

+8
include php require
source share
3 answers

A slash ( / ) precedes your path.

On a POSIX-compatible system, if you have a path starting with a slash, this means that it is an absolute path . The first slash is the root of the file system.

Remove the slash from your path, and then you should have a path related to page.php .

EDIT: Since relative paths will not work, you can use dirname(__FILE__) to get the absolute path to the directory where the current file is located.

 require(dirname(__FILE__) . '/includes/sess-start.php'); 
+8
source share

You need to use a relative path. When your file names begin with / PHP, it is assumed that you mean the root directory. The correct prefix ./

 include('./includes/sess-start.php'); 

If you want all your paths to be relative to the document root, this is a common method:

 include("$_SERVER[DOCUMENT_ROOT]/includes/sess-start.php"); 
+6
source share

It looks like you need to remove the leading slash from the include line.

Edit: to solve your problems. In the preend file or some common include, create a constant as DOCROOT . You can dynamically determine it from the __FILE__ constant.

Then:

 include(DOCROOT.'myfile.php'); 

Personally, I would try to fix everything in order to avoid this kind of thing.

+1
source share

All Articles