Solved

setting php include path on Windows XP?

Posted on 2008-11-02
7
2,212 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
  • 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

770 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