Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Include 1

Status
Not open for further replies.

TheSponge

Technical User
Jul 2, 2003
442
GB
I have a phpbb forum, which has a php shoutbox,

I want this box to show on the index.php page also (outside the forum directory)

I tried <?php include('/forum/shoutbox.php')?>

but it cannot find the path?

can anyone help please

(I can use <iframe> but I dont want to)

A+,Network +,CCNA
 
You have to be aware that for include() you need to use the filsystem path.
You have given the path from the server's DOCUMENT ROOT which is certainly different than the actual file path.
You can find out the part before the document root by looking at the phpinfo() output.

Another solution (less follproof) is to use a relative path to the file that contains the include statement. If you know that the shutbox is in the same folder you could just du include('shoutbox.php'), ../ for a level up etc.
 
oh!

and in english?

the root path is / surely?

A+,Network +,CCNA
 
to find out exactly where on the filesystem shoutbox lives, add an echo into it temporarily which is:

echo getcwd();

this will display the path you need to include()

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
add the echo getcwd() to the shoutbox, that will show you its true path, add the true path to index.php

- you may need to call the shoutbox directly first off to get the path, however that doesnt matter as you only need to see its true path the once and that will remain static wherever you cal it from.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
If you are editing the shoutbox anyway you should be able to determine the path in the file system.

I don't understand your reply to my post (especially the note about English).

Yes, '/' is the root, but it is the root of the filesystem not of the web server. The web server takes the document root as it's root. /forum/shoutbox.php is would be located in the root of the filesystem - which it obviously is not.

If you connect to your server via FTP you should be able to determine the file path with the pwd command.
 
I am still having problems with this..

my main site page is /
the forum is at /
the shoutbox shows up in the forum in /
shoutbox.php file has all the info in it for the inludes.

i would like the shoutbox to also show up on the main index.php page?

should I use <iframe>? frames?

I dont know, I would really appreciate help for a php learner.

MANY THANKS





A+,Network +,CCNA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top