PHP Includes()

NightFox

New Member
Messages
3
Reaction score
0
Points
0
Hey all,

I am trying to display a table in my main page using includes, however i cannot understand how to use them without them being used for a header / footer (and it was working fine 2 hours ago). Any ideas as to wat i have done wrong would be appriciated :) I know that the way i'm using php atm is simple (Hello World) but i need to get this working first before i can continue with the rest.

File to be included:(newsrecent.php)
Code:
			<table cellpadding="0" cellspacing="5">
				<tr>
                <!--Recent Threads-->
					<td><?php echo "Hello World"; ?>&nbsp;</td>
			  </tr>
				<tr>
					<td>&nbsp;</td>
			  </tr>				
				<tr>
					<td>&nbsp;</td>
			  </tr>				
				<tr>
					<td>&nbsp;</td>
			  </tr>				
				<tr>
					<td>&nbsp;</td>
			  </tr>						
				<tr>
					<td>&nbsp;</td>
			  </tr>									
			</table>

File linking to the include:(index.php)
Code:
<div id="rheadlines">
<?php include(newsrecent.php) ?>
		</div>

Regards

NightFox
 
Last edited:

diabolo

Community Advocate
Community Support
Messages
1,682
Reaction score
32
Points
48
it might/might not do anything, but i think a correct code is important

PHP:
<div id="rheadlines">
<?php include("newsrecent.php"); ?>
		</div>
 

NightFox

New Member
Messages
3
Reaction score
0
Points
0
Heh thanks for letting me know - it worked :)

funny how its the simple things that go wrong
 

lordskid

New Member
Messages
41
Reaction score
0
Points
0
are you sure it worked? I was pretty sure that you should do it this way.
PHP:
<?php include "newsrecent.php"; ?>

but then again if it worked then it worked. I'll take note of that too.
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,168
Reaction score
215
Points
63
are you sure it worked? I was pretty sure that you should do it this way.
PHP:
<?php include "newsrecent.php"; ?>
but then again if it worked then it worked. I'll take note of that too.

Include's a weird one - I've used it both ways and it seems to work both ways.

The key is making sure the " or ' are there, otherwise it freaks out :)
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
include() is a construct, not a function. Its syntax is similar to echo or return -- parentheses aren't required.
 
Top