Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-14-2004, 04:48 PM
WebProWorld Member
 

Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
wmabear54 RepRank 0
Default 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
Reply With Quote
  #2 (permalink)  
Old 05-14-2004, 05:00 PM
WebProWorld 1,000+ Club
WebProWorld Moderator
 

Join Date: May 2004
Location: Austin, TX
Posts: 1,331
jestep RepRank 0
Default

What is the code you are using to call the files?
Reply With Quote
  #3 (permalink)  
Old 05-14-2004, 05:14 PM
WebProWorld Member
 

Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
wmabear54 RepRank 0
Default

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
Reply With Quote
  #4 (permalink)  
Old 05-14-2004, 05:29 PM
WebProWorld Member
 

Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
wmabear54 RepRank 0
Default

I changed it and that didn't work

Stuumped
Reply With Quote
  #5 (permalink)  
Old 05-14-2004, 05:33 PM
WebProWorld 1,000+ Club
WebProWorld Moderator
 

Join Date: May 2004
Location: Austin, TX
Posts: 1,331
jestep RepRank 0
Default

Try
include "./giftdealsgalore/inc/header1.php";
Reply With Quote
  #6 (permalink)  
Old 05-14-2004, 05:35 PM
WebProWorld Member
 

Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
wmabear54 RepRank 0
Default

I'll try it

Mike
Reply With Quote
  #7 (permalink)  
Old 05-14-2004, 05:35 PM
ronniethedodger's Avatar
WebProWorld 1,000+ Club
 

Join Date: Aug 2003
Location: Central US
Posts: 1,581
ronniethedodger RepRank 0
Default

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');
?>
Reply With Quote
  #8 (permalink)  
Old 05-14-2004, 05:48 PM
WebProWorld Member
 

Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
wmabear54 RepRank 0
Default

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
Reply With Quote
  #9 (permalink)  
Old 05-14-2004, 06:42 PM
ronniethedodger's Avatar
WebProWorld 1,000+ Club
 

Join Date: Aug 2003
Location: Central US
Posts: 1,581
ronniethedodger RepRank 0
Default

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.
Reply With Quote
  #10 (permalink)  
Old 05-14-2004, 06:56 PM
WebProWorld 1,000+ Club
WebProWorld Moderator
 

Join Date: May 2004
Location: Austin, TX
Posts: 1,331
jestep RepRank 0
Default

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.
Reply With Quote
  #11 (permalink)  
Old 05-14-2004, 07:14 PM
WebProWorld Member
 

Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
wmabear54 RepRank 0
Default

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
Reply With Quote
  #12 (permalink)  
Old 05-14-2004, 07:54 PM
ronniethedodger's Avatar
WebProWorld 1,000+ Club
 

Join Date: Aug 2003
Location: Central US
Posts: 1,581
ronniethedodger RepRank 0
Default

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.
Reply With Quote
  #13 (permalink)  
Old 05-14-2004, 08:05 PM
WebProWorld Member
 

Join Date: Nov 2003
Location: Bedford, Va.
Posts: 72
wmabear54 RepRank 0
Default

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
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0