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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with PHP include 1

Status
Not open for further replies.

farw

Programmer
Feb 22, 2002
4
BR
Hello all,
i have just subscribe to this forum, in hope to find out the answer for this problem: I´m trying to configure a server using includes for generating dynamic pages, runing at apache and php 4.1. So, i´m testing and beginig to php, and have actually three similar php tags that follows:

<?php include (&quot;includes/body.html&quot;);?>

The problem is this conde works perfect on the root directory, but when I try to use on subdirectories, if failed. So I try this one:

<?php include (&quot;/includes/body.html&quot;);?>

in atempt to make php search the root directory, and imediatly the include directory where are those files. If failed again.

What is the correct synxtax to make this work under subdirectories?

Thanks,

Fernando Wendt
 
the function include includes files in the include_path as the local path or from the root if you use absolute paths.

One way to solve your problem is having a var named $root for example that have the path to the root of your files, then you do:

include($root.&quot;includes/file.php&quot;);

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Thanks Hugo,
but now it´s acusing another error...
Here is the page code, point me my mystakes:

<? php $root=&quot;/home/httpd/htdocs/&quot;; ?>
<? php include ($root.&quot;includes/scripts.html&quot;); ?>

So, whats wrong?
 
what error? Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Parse error, at this line:

<? php include($root.&quot;includes/scripts.html&quot;); ?>

So?
 
remove the php word

<? include($root.&quot;includes/scripts.html&quot;); ?>

or the blank space
<?php include($root.&quot;includes/scripts.html&quot;); ?>

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Finally it works!

Thank you again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top