Printer Friendly Version Print this thread
Email this thread to a friend eMail this thread to a friend
Related Forum Posts
  1. links from all the pages of another site (In: Google)
Featured Web Site Template

Hundreds More at Free Site Templates.com!

Web Site Partners
Sponsored Links
Jet City Software
 
Whos Here ?
Reflects user activity within the last 5 minutes
Moderator(s): Prowler, jcokos
Member Message

karrella
Joined: Aug 19, 2005
# Posts: 41

View the profile for karrella Send karrella a private message

Posted: 01/15/2007 04:16 pm
Edit Message Delete Message Reply to this message

Hello there, I have searched the forums for this topic and found a few similar problems but none much like mine.

My problem is with using the <?php include('info.php') ?> in files located in folders.

For example;
Here is the file I want to include..
www.example.com/info.php

Here is the page that should display the file
www.example.com/folder/page.php

Can I still write <?php include('info.php') ?> or do I need to do something special?

A page on the root directory will load fine, but soon as I use the include in a folder it will not show up and I get an error.

Do I have to format the include differently? I have tried all kinds of ways and can't seem to figure it out. These files I want to include save a lot of time because they are for menus and promotions etc.

Thanks



Prowler
Moderator
Joined: Aug 14, 2000
# Posts: 1720

View the profile for Prowler Send Prowler a private message

Posted: 01/15/2007 10:03 pm
Edit Message Delete Message Reply to this message

If this file www.example.com/folder/page.php has to call a file residing at the root, then you need to show the path where it can find it - like so :
<?php include('/info.php') ?>




karrella
Joined: Aug 19, 2005
# Posts: 41

View the profile for karrella Send karrella a private message

Posted: 01/16/2007 09:39 am
Edit Message Delete Message Reply to this message

I just tried that and nope I still get an error. It works at the root but not from the folder. I set it all up as a test and the folder has no fancy permissions or anything just a straight naked page with an include. In my test I'm using my navbar.php file which is currently working on many other pages and this is what it pukes out: (I censored part for security, but you get the drift)

Warning: main(/navbar.php) [function.main]: failed to open stream: No such file or directory in (my test folder) on line 8

Warning: main(/navbar.php) [function.main]: failed to open stream: No such file or directory in (my test folder) on line 8

Warning: main() [function.include]: Failed opening '/navbar.php' for inclusion (include_path='.:/usr/share/php4:/usr/share/php') in (my test folder) on line 8

So what do you think? Am I just doing something so simple wrong I cant see it? LOL



bhartzer
Administrator
Joined: Jun 08, 2000
# Posts: 7035

View the profile for bhartzer Send bhartzer a private message

Posted: 01/16/2007 10:11 am
Edit Message Delete Message Reply to this message

I know it's a workaround, but can't you just make a copy of info.php and put it in the same directory?



bhartzer
Administrator
Joined: Jun 08, 2000
# Posts: 7035

View the profile for bhartzer Send bhartzer a private message

Posted: 01/16/2007 10:14 am
Edit Message Delete Message Reply to this message

Okay, I found the info you need:

Edit the PHP configuration file so that you specify where the default file is located. If the include doesn't find it in the current directory, it will look for it wherever you have specified in the PHP configuration file.

There's more info here:
[link]

Info about the php include file is here:
http://www.hardcoder.com/scripting/php/config.php



karrella
Joined: Aug 19, 2005
# Posts: 41

View the profile for karrella Send karrella a private message

Posted: 01/16/2007 02:33 pm
Edit Message Delete Message Reply to this message

ok so I've used the info.php file, seen my info, located my file downloaded it, and checked it out. I'm not real sure what the instructions want me to do to it though. It does in fact talk about what I'm trying to do though and thats more info than I could find, Thanks bhartzer!
I'll keep searching around, look up some of the terms they use on that site. Everyones suggestions are still welcome, I haven't got this fixed just yet.

Thanks,



karrella
Joined: Aug 19, 2005
# Posts: 41

View the profile for karrella Send karrella a private message

Posted: 01/16/2007 02:49 pm
Edit Message Delete Message Reply to this message

This is what I think the other site is talking about but using the htaccess file.

Wrappers Code Instructions

Seems like a fairly good instructional page.

Well I'm off to go test that strategy.



karrella
Joined: Aug 19, 2005
# Posts: 41

View the profile for karrella Send karrella a private message

Posted: 01/16/2007 03:42 pm
Edit Message Delete Message Reply to this message

Bah! I get nothing from this Wrappers code. Maybe I'm missing something but I'm not going to get involved with a new project until I figure out my current problem.

As to the fist suggestion you made bhartzer, its useless to put a info.php file into each folder because when its time to update that will give me a info.php to update for each page i have, and thats not going to save me very much time. There isn't a lot of folders right now, only 8 but each of them have their own page that needs to include the file. The structure of the folders isn't my choice and must be like that for another script I'm running which have pages I can modify to match my current theme with headers and footers etc.

I don't know why this can't be as simple as Prowler suggestion, that would make this a lot less time consuming.



SportsGuy
Moderator
Joined: Aug 30, 2002
# Posts: 3593

View the profile for SportsGuy Send SportsGuy a private message

Posted: 01/17/2007 05:19 am
Edit Message Delete Message Reply to this message

Hey karrela.

All of my includes reside in a folder called "includes"

My htaccess file then lists, on one line, the path to follow for all includes.

Looks like this:



Code: [copy]





After that, the code I place on the actual page where I want the include to show up is as follows:



Code: [copy]





This should work, as it's the combo I currently have live. Try moving the files to include into their own folder and see if it like that better. It really shouldn't matter, but you never know...



karrella
Joined: Aug 19, 2005
# Posts: 41

View the profile for karrella Send karrella a private message

Posted: 01/17/2007 07:21 am
Edit Message Delete Message Reply to this message

Hey there,
when using this in htaccess (and changing it to my info)

php_value include_path ".:/domainnamehere.com/httpdocs/includes"

I just get an internal server error, does my htaccess file have to be set to a certain permission?

I can actually include files from folders, worked fine as it was with out the htaccess part I just found out. However the pages in the folders still will not load the files. If the folders or the page are set to a certain permission will that stop the include script from working? (I've tried both ways, and with fresh test folders, i'm just curious)

Thanks,



Prowler
Moderator
Joined: Aug 14, 2000
# Posts: 1720

View the profile for Prowler Send Prowler a private message

Posted: 01/19/2007 07:11 am
Edit Message Delete Message Reply to this message

.htaccess file can be left at the default permission value.

From the sanitized error report you have given, it seems obvious that the server is looking in the wrong place for the elusive info.php

A lot of things depend on your server configuration and at times things might change at the run time. So we are taking a peek in the dark at the moment as I can't see other factors.

Try another simple method: -
Put a ../ to jump back one level in the path like so:

<?php include('../info.php') ?> Assuming that your info.php resides one level above your test directory.





karrella
Joined: Aug 19, 2005
# Posts: 41

View the profile for karrella Send karrella a private message

Posted: 01/21/2007 06:29 am
Edit Message Delete Message Reply to this message

Bingo Prowler! The test of this worked! Will it work for multiple folders? ../../../info.php

Thanks!!



Prowler
Moderator
Joined: Aug 14, 2000
# Posts: 1720

View the profile for Prowler Send Prowler a private message

Posted: 01/22/2007 02:16 am
Edit Message Delete Message Reply to this message

It will. A caveat is in order here. The include files should preferably reside in the root or a directory directly from root, so that any file downstream can follow the path to the root without much problem.



karrella
Joined: Aug 19, 2005
# Posts: 41

View the profile for karrella Send karrella a private message

Posted: 01/22/2007 03:39 pm
Edit Message Delete Message Reply to this message

Well here's the good and the bad...
The good, you've fixed my problem, and it all works perfectly even from the 4th folder.

The bad part is on the particular page that I want it to work on, it won't because of the script that opens that page. I don't know cgi at all so it will be tough to fix I imagine.

If anyone is curious what this is all about, the script is for an online tarot card reader. There are several card layouts (the folders I had to go through) and then brief and long card readings (more folders). Then there is the index, which asks you your question about your fortune. When you click submit that runs the script and gives you a new page with your reading on it. This is the page where I was trying to use includes from. When the site is a little more complete and a little less plain, I'll link it to you all.

Thanks again everyone!



g1smd
Moderator
Joined: Jul 28, 2002
# Posts: 10181

View the profile for g1smd Send g1smd a private message

Posted: 01/23/2007 04:38 am
Edit Message Delete Message Reply to this message

I start all URLs like this with a / and provide the full folder path so that I never have problems with relative URLs.


You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
  1. You have not yet logged in, or registered properly as a member
  2. You are a member, but no longer have posting rights.
  3. This is a private forum, for which you do not have permissions.

If you are a recent member, it's possible that you simply have not yet confirmed your account. Please check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions contained within.

If you cannot find this message, click here to Re-Send it.

If you are still experiencing problem, please read the Login Assistance Article for some advice on what may be causing your login not to work properly.

Switch to Advanced Editor and ... Create a New Topic or Reply to this Thread

New posts Forum is locked
© 1995  ·  iWeb, Inc  ·  DBA JimWorld Productions