473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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 2540
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alexander Kienzle | last post by:
I'm new to Java programming. I'm developing a Servlet for tomcat which needs an external configuration file. With external I mean a file (in XML format) which is customizable and not contained in...
3
by: Robert | last post by:
I have an application with custom configuration sections in it's app.config file. Here's a shortened excerpt: <monitors> <monitor...
5
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to...
5
by: Arsalan Ahmad | last post by:
Hi all, I am developing a simple one page application in ASP.NET which takes an input in a text box and print in a label. But when i uploaded it to the website i get the following error: ...
4
by: TWEB | last post by:
I think I may have an IIS / ASP.Net Configuration issue that I need some guidance with resolving. Here's the problem: a) I have a .stm file. b) I referenc a .aspx file on this .stm file using a...
2
by: Terry Holland | last post by:
I posted a follow up to an earlier post but did not receive response so here it is again (with original post and response) > This could be because you are running the index service over this web...
5
by: NoNickname | last post by:
Basically, how do I know that the release versions of all components are being published? The Build | Configuration Manager is confusing me a little in VS2005. I have three projects in my...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.