Include

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Include

Post by phelpsa »

In my forum calendar, if you click on the link it breaks out of the 'include ()'. How can I stop this??

Adam
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

fix the code so it doesn't break.
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Post by phelpsa »

feyd wrote:fix the code so it doesn't break.
How do I do that?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

How do we know if we can't see your code.

Not 100% what you mean in any case.

Post your code and explain what you're trying to achieve. Surely your link just points to another file or chnages the arguments of the current location right?

You're currently in calendar.php (which includes a certain file right? index.php at a guess), so you're then linking to index.php and not surprisingly we end up at index.php when clicked.

You need to link to the page with the include() and use the appropriate arguments on that page.
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Post by phelpsa »

go to http://www.hillclimbsprint.co.uk/forum/calendarpage.php and click on 'Next Year'.

If you see it leaves the main page. How can I stop this.

The code is just:

Code: Select all

include ('www.hillclimbsprint.co.uk/forum/calendar/index.php')
Please be patient with me :(

Adam
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

including an external url requires the server to make a request and download that page, then pass the information on to you. Unless index.php returns php code when requested, you will only get the normal output of the file. If you want the php code that created the file, then you need to use a local include i.e. include('./calender/index.php') or simialr.
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Post by phelpsa »

When I do that it comes up with:
Warning: main(./includes/calendar.php): failed to open stream: No such file or directory in /home/www/hillclim/forum/calendar/index.php on line 66

Fatal error: main(): Failed opening required './includes/calendar.php' (include_path='.:/usr/local/lib/php') in /home/www/hillclim/forum/calendar/index.php on line 66
And it does exist.

Adam
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You probably mispelt it or need to go up a driectory or two ( .. ).

If it's in a subfolder of the root then take out the dot

/includes/calendar.php
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you're aware that paths and filenames are case sensitive correct? You may need to play with the path used, as it may be different than what you think..

for instance, does /home/www/hillclim/forum/calendar/includes/calendar.php exist?

/includes/calendar.php will not exist, as the root of the server is very likely to be inaccessible.
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Post by phelpsa »

It does exist, but it says it doesn't :? :?
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

Why are you adding the word includes in your path? You should be able to insert the line shown below just as it was suggested earlier.

Code: Select all

include('./calendar/index.php');

phelpsa wrote:When I do that it comes up with:
Warning: main(./includes/calendar.php): failed to open stream: No such file or directory in /home/www/hillclim/forum/calendar/index.php on line 66

Fatal error: main(): Failed opening required './includes/calendar.php' (include_path='.:/usr/local/lib/php') in /home/www/hillclim/forum/calendar/index.php on line 66
And it does exist.

Adam
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Post by phelpsa »

User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

If you are online, contact me via AIM or Yahoo Messenger.
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Post by phelpsa »

Thanks!!
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Post by phelpsa »

Ok, basically what we did was change the root path of the index to root from the directory which calendarpage.php

So originally it said

Code: Select all

phpc_root_path = './'
and we changed it to

Code: Select all

phpc_root_path = './calendar/'
Big thanks to john.

Adam
Post Reply