Solved

setting php include path on Windows XP?

Posted on 2008-11-02
7
2,207 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
php mail headers 2 14
populate dynamic drop down from a csv 3 41
Phone Dialer 5 38
regex expression 9 24
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 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

8 Experts available now in Live!

Get 1:1 Help Now