Solved

setting php include path on Windows XP?

Posted on 2008-11-02
7
2,216 Views
Last Modified: 2013-12-13
I have an interesting problem.  I have PHP installed on the system root of a Windows XP install (G:\PHP)

In my php.ini (G:\Windows\php.ini) I have the include path set to:

include_path = .;G:\php\includes

If I run a simple phpinfo(); however, under "PHP Core" the include path shows up as:

.;C:\php5\pear

And as a result it's throwing the obvious errors.   Where then, is that directive pulling from?

The obvious fix (and one thats tested/works) is to just create that said directory on the C partition and shove my included files into there, but the C partition belongs to another user, and I'd prefer to fix it properly.

 My first thought was an errant php.ini but I confirmed the loaded config file as G:\WINDOWS\php.ini


Any suggestions?

Thanks!
0
Comment
Question by:jmoriarty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 13

Assisted Solution

by:AielloJ
AielloJ earned 500 total points
ID: 22861812
The directive is being pulled from the Windows path.  The .ini file tells PHP how to find its files once it's running.  Next you have to tell Windows how to find the PHP files to get them running in the first place.  There's also a search order of how PHP looks for files.  I don't have the particulars in my head, but the process below will clear it up.

Add G:\WINDOWS to the default Windows path.  You can alter it by clicking on System in the Windows Control Panel, click on the Advanced tab, then click on the Environment Variables button at the bottom on the panel.
0
 

Author Comment

by:jmoriarty
ID: 22862652
Hi AielloJ,

Thanks for the comment! Unfortunately, that didn't fix it.  I'd already had G:\PHP in the environment path, and I did add G:\Windows like you suggested, but with, unfortunately, the same result.
0
 

Author Comment

by:jmoriarty
ID: 22862757
Hrm, maybe the problem is the format I'm using to set the directory? I was actually able to get it to change, I had forgotten quotes around the path, so it acted as if the line were commented I'm guessing.

I'm still getting weird include errors though.  

Here's what I have right now, to both set a specific directory (php\includes) and set the \includes directory one level above the current one. Is this the correct format to use for that on Windows?

include_path = "G:\php\includes; .\includes"

Thanks again.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Accepted Solution

by:
AielloJ earned 500 total points
ID: 22864049
jmoriarty:

What drive is PHP installed on?  I've found the php.ini file must be installed in the Windows folder (Usually C:\Windows) and the folder PHP is installed in (Usually C:\PHP).  The include path should also include the current folder (the dot), the folder PHP is installed in, as well as the includes folder.  I also suggest that all relative paths (.\includes) be formatted as full paths.  You can't make any assumptions about the base path Windows, and any other program, is using.  Thus a relative path easily introduces errors.  The following is the path in my php.ini file.  If you install PHP on the G; drive, then you should be able to not have to place any files in the C partition, except for a copy of the .ini file in the Windows folder.

include_path = ".;c:\php;c:\php\includes"
0
 

Author Comment

by:jmoriarty
ID: 22864641
PHP is installed on G:, which is the same as Windows. Structurally speaking, everything is installed as you've said -- except under G: instead of C: i.e., G:\Windows, G:\PHP, etc.  with the php.ini under G:\Windows\php.ini.

It does seem to be more of a relative path issue at this point though.  

I.E., if I write:

include_once("classes\db.inc.php"); (where classes is a sub directory under the "includes" directory) it doesn't work, but if I use the full path of

include_once("G:\Inetpub\wwwroot\includes\classes\db.inc.php"); it works fine.  I suppose that's a solution, to fully qualify each file path, but there's a good 40 of 'em, so I was trying to find a better way to make relative paths work.

Thanks for the verification on the include_path directive as well.
0
 
LVL 13

Expert Comment

by:AielloJ
ID: 22865831
The php.ini file should also be in the G:\PHP directory.  I've found that it has to be in both places.
0
 

Author Closing Comment

by:jmoriarty
ID: 31512464
Thanks - sorry for the delay in response.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

752 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