x10Hosting Forums

Corporate Free Hosting for the Masses.



Register

Reply
 
LinkBack Thread Tools Display Modes
x10Hosting Member

Join Date: Oct 2008
Posts: 11
Credits: 334
stillDOLL is on a distinguished road
Quote  
10-06-2008, 06:56 AM
Question PHP Include, file help!

I'm new to PHP but I just mangaged to put the content which I am going to use on all my pages on a "header.php" file and the other content which I put on a "footer.php" file. And the tutorial I was reading says to type in the script like this:

<?php include('header.php'); ?>
<div style="position: absolute; left: 246; top: 619; width: 574; height:180">
<div style="width: 574; height: 224"><p class="Header">Welcome~</div>
</div>
<?php include('footer.php'); ?>

I've done that and I even uploaded the "header" and the "footer" onto my server but when I upload this as one PHP file (main.php) and preview it it's just a blank screen with "Welcome~" on it!! >w<

Can someone please tell me what I'm doing wrong? and if I'm not doing this wrong does x10 support PHP??


Thanks!~^^,

Ann

-btw, if you don't get what I'm saying please feel free to email me at vampireheart.stilldoll@hotmail.com
Reply With Quote
stillDOLL is offlineReport Post
x10 Lieutenant

freecrm's Avatar

Join Date: May 2008
Posts: 272
Credits: 956
freecrm will become famous soon enough
Location: UK

Quote  
10-06-2008, 08:03 AM
Re: PHP Include, file help!

Couple of things to watch out for here...

Firstly, all my includes have double quotation marks (") but I'm not sure that has any relevance.

More importantly is the location of the included file. If they are in the same directory as the file you are including them into - there shouldn't be a problem but if they are in a directory above/below/different - you need to specify the path correctly.

Lastly (and this is probably the reason), your included file can only be the body part of a page. In other words, you need to strip out everything above (and including) <body>

Very simply put, your included files should only have code like this...

PHP Code:
<table>
<tr>
<td>Welcome</td>
</tr>
</table>
<?php echo $_SESSION['username']; ?>
If headers, opening or closing tags are in the include file, it confuses the page you are including them in.

Your main page would look something like this.

PHP Code:
<html>
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php include("header.php"); ?>
<div style="position: absolute; left: 246; top: 619; width: 574; height:180">
<div style="width: 574; height: 224"><p class="Header">Welcome~</div>
</div>
<?php include("footer.php"); ?>
</body>
</html>
Yes, X10 does support php!
__________________
Rich

If you liked this post, please give me +rep or donate credits.

My Site:
Reply With Quote
freecrm is offlineReport Post
x10 Sophmore

Scoochi2's Avatar

Join Date: Aug 2008
Posts: 118
Credits: 1,277
Scoochi2 will become famous soon enough
Location: Southport!

Quote  
10-06-2008, 08:03 AM
Re: PHP Include, file help!

Quote:
Originally Posted by stillDOLL View Post
<?php include('header.php'); ?>
<div style="position: absolute; left: 246; top: 619; width: 574; height:180">
<div style="width: 574; height: 224"><p class="Header">Welcome~</div>
</div>
<?php include('footer.php'); ?>

I've done that and I even uploaded the "header" and the "footer" onto my server but when I upload this as one PHP file (main.php) and preview it it's just a blank screen with "Welcome~" on it!! >w<
Hmm. I would ask if the header and footer are named exactly that, not header.php.html or anything, and that they are in the same directory as the file that includes them.
But if that was the case, PHP would give an error.

Because you get no errors, I can only assume that your header and footer are either blank, or have no output in them. For example, the following example header.php will output nothing and would look exactly like what you're getting above.
PHP Code:
<?php
$a 
10;
$b 3;
$c $a $b;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head>
<title>Index page</title></head><body>
One other thing to check, the file that is trying to include is a PHP file, right? But again, it would output the PHP code if it was HTML...
index.php?


Have you viewed the source of your file? Because if you look at my example above, it will show nothing on the page. But it will output the headers in the source...
__________________
If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending...

Last edited by Scoochi2; 10-06-2008 at 08:06 AM.
Reply With Quote
Scoochi2 is offlineReport Post
x10Hosting Member

Join Date: Sep 2008
Posts: 4
Credits: 219
sycoblast is on a distinguished road
Quote  
10-06-2008, 11:27 AM
Re: PHP Include, file help!

<?php include('header.php'); ?>
<div style="position: absolute; left: 246; top: 619; width: 574; height:180">
<div style="width: 574; height: 224"><p class="Header">Welcome~</div>
</div>
<?php include('footer.php'); ?>


--------

Instead of "including"

why not just "echo" your header/footer ... or if your page is scripted in HTML just have it in "class" text so you can avoid using headers and footers... It also slows down the page when you have excessive .php scripts for no reason... Like this.
Reply With Quote
sycoblast is offlineReport Post
x10 Lieutenant

freecrm's Avatar

Join Date: May 2008
Posts: 272
Credits: 956
freecrm will become famous soon enough
Location: UK

Quote  
10-06-2008, 12:03 PM
Re: PHP Include, file help!

Quote:
Originally Posted by sycoblast View Post

why not just "echo" your header/footer ...
Interesting point.. what's the syntax for this and why do we even have an include function?

If you echo a page, does it process any included php?

What are the pro's con's?
__________________
Rich

If you liked this post, please give me +rep or donate credits.

My Site:
Reply With Quote
freecrm is offlineReport Post
x10Hosting Member

Join Date: Sep 2008
Posts: 66
Credits: 727
exemption is on a distinguished road
Quote  
10-06-2008, 01:52 PM
Re: PHP Include, file help!

Why use HTML inside of PHP when you can simply use PHP through out?

such as this

PHP Code:
<?php
include "header.php";
include 
"w/e.php";
include 
"file.html";
?>
'
something like that is super simple
__________________


I program PHP..so if you need help lemme know!

Reply With Quote
exemption is offlineReport Post
x10 Sophmore

Join Date: Jul 2008
Posts: 144
Credits: 1,416
xav0989 is on a distinguished road
Quote  
10-06-2008, 09:44 PM
Re: PHP Include, file help!

What I do is I create a header and footer template in html, and I have a function that reads them and echos them. This is, in my opinion, the simplest way.
__________________
Use a great CMS, try eaCyMS (not available now... yet!)

Pain is weakness leaving the body.
Reply With Quote
xav0989 is offlineReport Post
x10Hosting Member

Join Date: Oct 2008
Posts: 11
Credits: 334
stillDOLL is on a distinguished road
Quote  
10-07-2008, 02:44 AM
Re: PHP Include, file help!

Hey!!^^ Thanks everyone who replied!!!^^ I've got the problem fixed now XD
So thank you very very much!!!!^^
Reply With Quote
stillDOLL is offlineReport Post
x10 Sophmore

dickey's Avatar

Join Date: Sep 2008
Posts: 118
Credits: 2,562
dickey is on a distinguished road
Location: Singapore

Send a message via Yahoo to dickey
Quote  
10-07-2008, 05:26 AM
Re: PHP Include, file help!

Then I guess you have to close this thread. post one more time and tick the close thread option. before posting.
Reply With Quote
dickey is offlineReport Post
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
include php within javascript thezone1 Programming Help 5 04-24-2008 01:50 PM
PHP version + max file size limit tipsyman Free Hosting 3 02-27-2008 02:04 PM
How to include As(Flash Action Script File) file in Flash. satheesh Tutorials 0 10-10-2007 08:53 AM
"PHP Startup: Invalid Library" - Interesting error javaguy78 Free Hosting 5 03-27-2007 03:33 PM
Converting a .RMVB file SEÑOR Off Topic 7 06-19-2006 03:20 PM


All times are GMT -5. The time now is 06:52 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC7
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

MPAA | Loans | Mortgage Calculator | Mobile Phone deals | Loans