Forum Moderators: coopster

Message Too Old, No Replies

php include not working

         

rasin

11:29 am on Aug 22, 2005 (gmt 0)

10+ Year Member



hi
i ahve main.html page and another another.html or txt file that i want to use inside the main.html
i prefer using the php include
i read on the forum how to do it but i cant make it work

here the code of main.html:

<td width="153" rowspan="3" valign="top"><p align="left"><?php include("/menu.html");?>
</td>

and the another.html(menu.html) :

<h2>this is external html</h2>

please help

encyclo

12:14 pm on Aug 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums, rasin. :)

PHP includes reference files from the server root rather than the document root, so using a path like

/menu.html
will mean that the PHP parser won't be able to find the file. I prefer doing avoiding the use of an absolute file path, so I do this:

<?php include[b]($_SERVER["DOCUMENT_ROOT"].[/b]"/menu.html");?>

rasin

12:19 pm on Aug 22, 2005 (gmt 0)

10+ Year Member



still nothing

PumpkinHead

4:26 pm on Aug 22, 2005 (gmt 0)

10+ Year Member



Hi,

Try this...

Firstly, rename both files to .php not .html

Then use this code...

<td width="153" rowspan="3" valign="top">
<p align="left">
<?php
include("menu.php");
?>
</p>
</td>

Hope that works, good luck!