Php inclusion error

Posted on 2006-04-07
Last Modified: 2006-11-18
when I try to access some php pages, I get this error:

Warning: Failed opening 'E:\websites\cms\index.php\admin\user\login\' for inclusion (include_path='.;C:\php\includes;C:\php\pear') in Unknown on line 0

I am using Windows xp+iis+php

I installed php at c:\php; there are two folders, includes (no files) and pear (many files) under c:\php

My php.ini is at c:\windows\system32.

a fragement of php.ini is:

include_path = ".;C:\php\includes;C:\php\pear"

Where did I make mistakes? Thanks

Question by:tiger0516
    LVL 7

    Expert Comment

    The php page you are trying to access is in turn calling additional files that it cant find. This is probably going to be less about how php is installed and specifically related to the scripts your running and getting the errors from. Without knowing whats scripts they are running or seeing some code it will be tough to point out the exact cause.

    LVL 18

    Expert Comment

    Hi tiger, you haven't made a mistake when installing php or the path to your pear libraries.

    When you include your files in your php file, make sure that they are relative to the script.  If you are using a slash before the directory and file name (e.g. include("/mydirectory/myfile.php"), sometimes php could interpret this slash as an actual disk path.  Be sure to use something like this instead include("mydirectory/myfile.php").  Failing that then you need to ensure that your files that you are including actually exist.  
    LVL 18

    Expert Comment

    Oh, I've also just noticed that you have e:\websites\cms\index.php\admin\user\login\ as your path to the file that was being included.  This is interesting because there is a file called index.php in the cms directory, so how can a file have directories after it as in \admin\user\login\?  This could mean that you are calling a function similar to:




    Now, I'm also not sure why the directory login is being called in the include.  There should actually be a file in the login directory that the include is trying to locate, however your error above doesn't state what the file should be called.  This is very strange.  I've tried these functions out and both have produced very similar results to the one you have provided above and I get the error firstly because the files don't exist and also because the include is calling a directory after the file name.

    If you can find out what the file is called, I would rewrite the include to something like:


    or something along those lines and then your script will be able to resolve it's path and retrieve the contents of that file for inclusion.

    Furthermore, if the absolute path is required then you could simply remove the $_SERVER["PHP_SELF"] part from the first bit of code above, eg:

    <? include($_SERVER["DOCUMENT_ROOT"]."/admin/user/login/");?>

    Additionally, it is possible that the CMS you are using is not fully supported by windows due to the differences in directory calling.  In this case I would contact the developers of the scripts you are using and state the above error message.  It's possible that they could provide a fix, or there may already be one published on their forums.  

    Hope this helps.
    LVL 1

    Author Comment

    Hi Lhotch & ingwa,

    I just realized it is probably because of URL rewrite. My program, EZ publish, is supposed to run in Apache, which has built-in URL rewrite support. However, due to our IT personeel cannot install Apache for us, I have to use IIS and I built my local machine the same config our server is.

    It is really a big problem.
    LVL 18

    Accepted Solution

    Tiger, I have previously managed to successfully run php on IIS using the api or dll that php provides for integration.  Whilst this process is complicated to get perfect, it can be done.  However I hope that the above examples have helped you narrow down the issues with your include that you first stated.  As far as I see, PHP is correctly running, however to confirm this, there are three commands that I would recommend that you try in a test.php file.

    Firstly, setup a file called phpinfo.php and include the following line in it:

    <? echo phpinfo(); ?>

    This should give you a very nicely formatted webpage which gives you a very detailed explanation on your php system and what is included in the libraries such as pear, GD, curl, etc.  

    Secondly, open up test.php as a blank text document and type in <? echo "hello"; ?>.  If this prints hello into the page when you browse it then the basics of php are correctly setup.

    Finally, setup a file called test2.php and have this statement in it:

    <? include("test.php"); ?>

    This should have the same results as what you got in test.php.  If this runs correctly then I certainly don't see a problem with your php setup.  What I would further recommend is having a look at the IIS server error logs to see what the php api is sending to it.  These can be pretty useful in diagnosing problems with your scripts, or php setup.

    However, I haven't really used URL rewrite before so you could be on the right analysis of the situation.  Did you know that I have also managed to run apache alongside an IIS installation on the same box?  Simply install php on the box with a seperate port number, or if you are privillaged enough (by your IT department of course) to setup an additional IP address on the box, then use the primary IP address for IIS and the Secondary for Apache.  Apache has a nice download available for windows based systems and you shouldn't have too many difficulties in getting it setup.  If your technology department is worried about the security vulnerabilities of what you are doing, ask them for a spare pc (they have to have one, every IT department regularly repairs old systems, replaces them with new ones) and setup Windows server with iis on it.  And then install Apache.  As it's only a staging box, your security issues shouldn't be a problem as the machine won't have access to system critical functions or facilities and it enables you to test the environment that you wish to develop in.

    Hope this helps.

    LVL 18

    Expert Comment

    Tiger, I'm happy to hear that you found some of my suggestions above useful.  Would it be possible to know what the solution was?  It could be helpful for other people in your situation to know exactly what helped, and would help my curiosity :)  Thanks for the points and for the grade.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now