 |

05-14-2004, 04:48 PM
|
|
WebProWorld Member
|
|
Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
|
|
php error
Hi all
I am getting error in the php logs, when I call for the index.php that is made up of 3 inc's this is the error that I get.
[13-May-2004 14:53:29] PHP Warning: main(C:/apache2/htdocs/inc/header1.php): failed to open stream: No such file or directory in C:\apache2\htdocs\giftdealsgalore\index.php on line 2
[13-May-2004 14:53:29] PHP Warning: main(): Failed opening 'C:/apache2/htdocs/inc/header1.php' for inclusion (include_path='.;c:\apache2\php;c:\apache2\php\sma rty;c:\apache2\php\pear;c:\apache2\php\pear\pear') in C:\apache2\htdocs\giftdealsgalore\index.php on line 2
It's not that I don't understand that the inc dir. needs to be in the dir. of giftdealgalore it is according to the file structure at the command promt.
It appears to me that php looked for the inc here 'C:/apache2/htdocs/inc/header1.php' when it should have looked here
'C:/apache2/htdocs/giftdealsgalore/inc/header1.php'
everything works fine on the remote host this is on localhost.
any ideas
Mike
|

05-14-2004, 05:00 PM
|
|
WebProWorld 1,000+ Club
|
|
Join Date: May 2004
Location: Austin, TX
Posts: 1,331
|
|
What is the code you are using to call the files?
|

05-14-2004, 05:14 PM
|
|
WebProWorld Member
|
|
Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
|
|
Thanks Jestep
This is the code, and this has given me a idea that maybe calling for the code locally may be different than callin it remotelly I may not have local site set up right yet still very confusing. Think I will change what is below
<?php
include $_SERVER['DOCUMENT_ROOT']."/inc/header1.php";
include $_SERVER['DOCUMENT_ROOT']."/inc/leftcol.php";
include $_SERVER['DOCUMENT_ROOT']."/inc/rightcol.php";
?></div>
</div>
<div align="center">
[img]/giftsgalore_1aaa.jpg[/img]</p>
</p>
</p>
</div>
</div>
</body>
</html>
to
<?php
include $_SERVER['DOCUMENT_ROOT']."/giftdealsgalore/inc/header1.php";
include $_SERVER['DOCUMENT_ROOT']."/giftdealsgalore/inc/leftcol.php";
include $_SERVER['DOCUMENT_ROOT']."/giftdealsgalore/inc/rightcol.php";
?></div>
</div>
<div align="center">
[img]/giftsgalore_1aaa.jpg[/img]</p>
</p>
</p>
</div>
</div>
</body>
</html>
Do you think maybe that is it
Mike
|

05-14-2004, 05:29 PM
|
|
WebProWorld Member
|
|
Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
|
|
I changed it and that didn't work
Stuumped
|

05-14-2004, 05:33 PM
|
|
WebProWorld 1,000+ Club
|
|
Join Date: May 2004
Location: Austin, TX
Posts: 1,331
|
|
Try
include "./giftdealsgalore/inc/header1.php";
|

05-14-2004, 05:35 PM
|
|
WebProWorld Member
|
|
Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
|
|
I'll try it
Mike
|

05-14-2004, 05:35 PM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Aug 2003
Location: Central US
Posts: 1,581
|
|
Try something like this:
Code:
<?php
$app_root_path = './';
include($app_root_path . 'inc/header1.php');
include($app_root_path . 'inc/leftcol.php');
include($app_root_path . 'inc/rightcol.php');
?>
|

05-14-2004, 05:48 PM
|
|
WebProWorld Member
|
|
Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
|
|
Hi Jestep
include "./giftdealsgalore/inc/header1.php"; Well that did work. Thanks
Hi Ron
I think I will try your way too a little later.
There still must be something wrong though, because I thought that I should have the same file structure for the remote and testing server.
Mike
|

05-14-2004, 06:42 PM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Aug 2003
Location: Central US
Posts: 1,581
|
|
Quote:
|
Originally Posted by wmabear54
There still must be something wrong though, because I thought that I should have the same file structure for the remote and testing server.
|
The way I read your code is that it appeared that even though the file structure might be the same, your directory for /giftdealsgalore/ is one directory up from the root on your local server.
This is why I included the $app_root_path = './'; in my example to establish the current working directory to use as a reference point. No matter where you move the code now, it will always be based on the reference point. In other words...it will work in root/ and root/giftdealsgalore/ too.
|

05-14-2004, 06:56 PM
|
|
WebProWorld 1,000+ Club
|
|
Join Date: May 2004
Location: Austin, TX
Posts: 1,331
|
|
Quote:
|
No matter where you move the code now, it will always be based on the reference point
|
I agree, this is why I always use this format in includes, I dont have to change the code no matter where the page happens to be.
|

05-14-2004, 07:14 PM
|
|
WebProWorld Member
|
|
Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
|
|
Yes Ron that's right I think that on the testing or localhost the doc root is in the wrong place. So what you are saying is that using $app_root_path = './'; in the inc file on the remote server and on the testing server will allow both to work properly. What my goal is, is to have the same exact files on the remote and testing (afraid I will upload the wrong set to one or the other) I want to mirrow my remote.
Mike
|

05-14-2004, 07:54 PM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Aug 2003
Location: Central US
Posts: 1,581
|
|
Yes. Using a variable to store the current directory in will make the code portable.
I had the same problem you are going thru, and learned it the hard way. ;0)
I have a local server too ... and the directory for some of the sites are two or three levels up from the root. So I know that it works.
Example Webstractions Test Site and another test site. Both sites use a path variable to establish what directory they are in. The code can be transferred to any other directory or the root of a server and still work.
|

05-14-2004, 08:05 PM
|
|
WebProWorld Member
|
|
Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
|
|
Thhanks Ron great info
Now I should be able to more on at a quicker pace and not worry about tweaking the local server to mimmick the remote as much.
Mike
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|