Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 5th, 2006, 09:45 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default Include File

I found this piece of code for using include files.
<?php include("top.html"); ?>

But I can't get it to work. What else do I need to make this work. I am used to asp but my web server only supports PHP.

Thanks

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
__________________
-----------------------------------------------------------
\"Don\'t follow someone who\'s not going anywhere\" John Mason
 
Old January 5th, 2006, 05:35 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try a different file. For example top.txt.
I don't see any errors in your script.
John


 
Old January 6th, 2006, 07:01 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

top.html need be in same directory of what PHP script in whcih you included it.

If it is in other directory, there may be path problem.
use echo get_include_path(); to know include_path.

`~@#\^%&*/\.<.\/-|+|_!:;..=?>
Students' finances
 
Old January 6th, 2006, 09:10 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the reply's, The file is in the same Directory. I can't use a txt file because I am trying to include the top navigation for my website, so it has to be a .html file. Is it possible I am using the wrong version of PHP? Also I don't get any error's or anything when I load the page with the include code. So I don't really know how to trouble shot this, when the webpage loads the same, with or without the code.

Thanks

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
 
Old January 8th, 2006, 10:30 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if the file contain php code:
<?php include("top.php"); ?>
if the file contain html code:
<?php include("top.inc"); ?>
 
Old January 10th, 2006, 09:31 AM
Registered User
 
Join Date: Jan 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Anupam Chatterjee
Default

Can you please be more specific with "can't get it to work". It would be a great help if you can narrate any error messages that you might be receiving or the output ur getting

 
Old January 11th, 2006, 10:31 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Does anyone know what Mantis Means? As stated above nothing happenes when I load the page. No error messages, it's like the code is not there.

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
 
Old January 15th, 2006, 12:29 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The include allow you to add piece of code which are repititive like menu's shortcut.

For example:
Index.html:

<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Index Test</title>
</head>
<body>

<p align="center"><i><b>Hello World</b></i></p>
<p align="center">[link1]&nbsp; [link2]&nbsp; [link3]</p>
<p align="center">&nbsp;</p>
<p align="center"><b><i>Welcome to our website</i></b></p>

</body>
</html>

Now if you have a menu of 10+ links the last thing you want to do is to open every pages and change the menu lines everytime there is a new link; So you use include like this:

Index.PHP:

<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Index Test</title>
</head>
<body>

<p align="center"><i><b>Hello World</b></i></p>
<?php include ("menu.inc"); ?>
<p align="center">&nbsp;</p>
<p align="center"><b><i>Welcome to our website</i></b></p>

</body>
</html>

and create a new file:
menu.inc:
<p align="center">[link1]&nbsp; [link2]&nbsp; [link3]</p>
 
Old January 17th, 2006, 09:30 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help :)

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason





Similar Threads
Thread Thread Starter Forum Replies Last Post
Include file trouble rstelma ASP.NET 1.0 and 1.1 Professional 3 February 12th, 2008 01:21 PM
Include file morpheus BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 April 23rd, 2006 08:20 AM
difference between include file & include virtual crmpicco Classic ASP Basics 2 January 23rd, 2006 11:50 AM
Include file within aspx jieli1001 ASP.NET 1.0 and 1.1 Professional 2 July 29th, 2003 04:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.