469,623 Members | 1,544 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

Php configuration - include path problem

Hi,

I've got a php script located at : http://localhost/browse/script.php
This script is "URL-rewrited" as http://localhost/welcome.htm

This script includes other scripts with the following code :

<?php
include("../inc/connect.php") ;
....
?>

When I directly type : http://localhost/browse/script.php => it works
As when I go to : http://localhost/welcome.htm => Error could not find
"../inc/connect.php" !!

I've just changed my apache/php/mysql conf (and unfortunately lost the one I
had before) : I switched to xampp.
This script used to work perfectly before :-( !!!
I do understand that paths are different for the client code but I don't
understand why it could be the same with server code !
I suspect Apache / Php conf to be the cause of my problem... but I can't
find out !
Can you help me, it's quite importante.

Thanks in advance,

--
alex
Mar 8 '06 #1
13 2370
alex wrote:
Hi,

I've got a php script located at : http://localhost/browse/script.php
This script is "URL-rewrited" as http://localhost/welcome.htm

This script includes other scripts with the following code :

<?php
include("../inc/connect.php") ;
...
?>

When I directly type : http://localhost/browse/script.php => it works
path is like:
/home/user/www/inc/connect.php
As when I go to : http://localhost/welcome.htm => Error could not find
"../inc/connect.php" !!
path is like:
/home/user/inc/connect.php
I do understand that paths are different for the client code but I don't
understand why it could be the same with server code !
You may have had the include path set with the "inc" directory included.

include_path = ".:./inc"
I suspect Apache / Php conf to be the cause of my problem... but I can't
find out !
Can you help me, it's quite importante.

Thanks in advance,

Mar 8 '06 #2
> You may have had the include path set with the "inc" directory included.

include_path = ".:./inc"


thanks, but this would only work for this particular file.
In fact, I have many scripts in many different directories (several projects
on the same machine : localhost/project_A, localhost/project_B, ...).
I would be impossible to maintain if I had to update the "include_path" var
every time I get a new project.
The trouble is I never changed this option before and it used to work. I
can't understand why.

FYI : I run under windows and my current "include_path" is :
include_path = ".;C:\Program Files\xampp\php\pear\"

it's the default value in xampp.
Mar 8 '06 #3
> I would be impossible to maintain if I had to update the "include_path"
var every time I get a new project.


Sorry, this is a mistake... the '.' directory in the include_path would
solve my pb... but it doesn't :'-(
Mar 8 '06 #4
alex wrote:
I would be impossible to maintain if I had to update the "include_path"
var every time I get a new project.


Sorry, this is a mistake... the '.' directory in the include_path would
solve my pb... but it doesn't :'-(


try adding it like:

include_path = ".:/path/to/inc"
Mar 8 '06 #5
> try adding it like:

include_path = ".:/path/to/inc"


it doesn't work :-(
Mar 8 '06 #6
alex wrote:
try adding it like:

include_path = ".:/path/to/inc"


it doesn't work :-(

Just to be clear.
"/path/to/inc" in your case is an absolute path not a relative one - right?

For example:
if your web site is hosted in /opt/web/my_site
and your include files are in /opt/web/my_site/includes

then your include_path would be ".:/opt/web/my_site/includes"

-david-

Mar 8 '06 #7
alex wrote:
Hi,

I've got a php script located at : http://localhost/browse/script.php
This script is "URL-rewrited" as http://localhost/welcome.htm

This script includes other scripts with the following code :

<?php
include("../inc/connect.php") ;
...
?>

When I directly type : http://localhost/browse/script.php => it works
As when I go to : http://localhost/welcome.htm => Error could not find
"../inc/connect.php" !!

I've just changed my apache/php/mysql conf (and unfortunately lost the one I
had before) : I switched to xampp.
This script used to work perfectly before :-( !!!
I do understand that paths are different for the client code but I don't
understand why it could be the same with server code !
I suspect Apache / Php conf to be the cause of my problem... but I can't
find out !
Can you help me, it's quite importante.

Thanks in advance,


For stuff based off your website's root directory, don't even use the
include path. Just use absolute paths based on the document root, i.e.

$_SERVER['DOCUMENT_ROOT']] . '/inc/connect.php'

Works in every setup of Apache, and is transportable. No .ini file
changes required.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 8 '06 #8
> Just to be clear.
"/path/to/inc" in your case is an absolute path not a relative one -
right?
For example:
if your web site is hosted in /opt/web/my_site
and your include files are in /opt/web/my_site/includes

then your include_path would be ".:/opt/web/my_site/includes"

-david-


Ok, it's clear.
Still, it doesn't work :-(
I think it comes from the URL rewriting as the "not URL-rewrited" file works
but not the "URL rewrited" one.
What do you think ?
Mar 8 '06 #9
alex wrote:
Just to be clear.
"/path/to/inc" in your case is an absolute path not a relative one -
right?
For example:
if your web site is hosted in /opt/web/my_site
and your include files are in /opt/web/my_site/includes

then your include_path would be ".:/opt/web/my_site/includes"

-david-


Ok, it's clear.
Still, it doesn't work :-(
I think it comes from the URL rewriting as the "not URL-rewrited" file works
but not the "URL rewrited" one.
What do you think ?

Follow Jerry Stuckle's advise and make the include relative to
$_SERVER['DOCUMENT_ROOT'].

In my case, my includes are not in the web tree, so setting the path is
appropriate.

BTW: I don't think URL rewriting has any affect on the include_path
since a) the path is absolute and b) PHP does care about URLs.

-david-

Mar 8 '06 #10
d
"alex" <al**@nospam.org> wrote in message
news:44***********************@news.free.fr...
You may have had the include path set with the "inc" directory included.

include_path = ".:./inc"

thanks, but this would only work for this particular file.
In fact, I have many scripts in many different directories (several
projects on the same machine : localhost/project_A, localhost/project_B,
...).
I would be impossible to maintain if I had to update the "include_path"
var every time I get a new project.
The trouble is I never changed this option before and it used to work. I
can't understand why.


You should use subhosts to keep your sites sane on your machine. Keeping
seperate sites on one domain is asking for trouble :)
FYI : I run under windows and my current "include_path" is :
include_path = ".;C:\Program Files\xampp\php\pear\"

it's the default value in xampp.

Mar 9 '06 #11
Sorry, I was away for a while.
Follow Jerry Stuckle's advise and make the include relative to
$_SERVER['DOCUMENT_ROOT'].
Ok, my problem is that I have many included scripts to change :-(
In my case, my includes are not in the web tree, so setting the path is
appropriate.

BTW: I don't think URL rewriting has any affect on the include_path since
a) the path is absolute and b) PHP does care about URLs.


That's exaclty what I think... and it's the case on my production server
(and it was on my local machine few days ago).
Still, with my brand new xampp set up on my local dev machine, I now have
this problem (I didn't encounter it before with apache/php/mysql and zend
server).

I found a "solution" => adding http redirection in all my rewrite
conditions, i.e :
before : RewriteCond ^test$ /test.htm
after : RewriteCond ^test$ /test.htm [R=304]

It works but doesn't really satisfy me.

--
alex
Mar 11 '06 #12
> You should use subhosts to keep your sites sane on your machine. Keeping
seperate sites on one domain is asking for trouble :)


Thanks, I didn't know this.
--
alex
Mar 11 '06 #13
alex wrote:
Sorry, I was away for a while.

Follow Jerry Stuckle's advise and make the include relative to
$_SERVER['DOCUMENT_ROOT'].

Ok, my problem is that I have many included scripts to change :-(


And the longer you wait, the more work it will be.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 11 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Alexander Kienzle | last post: by
5 posts views Thread by David Mathog | last post: by
5 posts views Thread by Arsalan Ahmad | last post: by
2 posts views Thread by Terry Holland | last post: by
5 posts views Thread by NoNickname | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.