Problem with dynamic php include -- SOLVED --

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Blackframe
Forum Newbie
Posts: 3
Joined: Thu Dec 17, 2009 4:28 am

Problem with dynamic php include -- SOLVED --

Post by Blackframe »

Hi there
I am using the below code on a test.php page just before I start building the actuall website. The problem I encountered was with IE6 and IE7 where a gap appears just before the actual content. When viewing the source code with IE8 developer tool, I see a small box as (?). Basically this creates a space just before the content and I am sure this will cause some problems in the future. Is something I'm doing wrong?

Note: there is no problem with IE8 and firefox.

You can see what I'm talking about at:
http://www.bridegroom.0fees.net/test.php?page=home
and
http://www.bridegroom.0fees.net/test.php?page=contact

Code: Select all

<!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">
<head>
<title> Homepage | <?php echo $_GET['page']; ?> </title>
 
<style type="text/css">
* {
    margin: 0;
    padding: 0;
}
</style>
</head>
 
<body>
 
<?php
 
$page = strip_tags($_GET['page']);
 
if (!$page) {
  $include = 'home.php';
  include ($include);
}
else {
  $include = ''.$page.'.php';
  include ($include);
}
?>
 
</body>
</html>
 
Cheers!!!
Last edited by Blackframe on Tue Dec 22, 2009 8:12 am, edited 1 time in total.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Problem with dynamic php include

Post by papa »

Dunno

Code: Select all

 
$include = $page.'.php';
 
or
 
include (trim($include));
 
 
Blackframe
Forum Newbie
Posts: 3
Joined: Thu Dec 17, 2009 4:28 am

Re: Problem with dynamic php include

Post by Blackframe »

Tried that but still the space remains. :-((((
... any other thoughts will be much appreciated.
indian98476
Forum Commoner
Posts: 78
Joined: Tue Dec 15, 2009 3:24 am

Re: Problem with dynamic php include

Post by indian98476 »

when i debugged it in firefox i found a paragraph tag i.e. <p></p> in the beginning of the body....when i removed it it worked....check source for that html file.....dont kno if its sure...i just tried to tell wht i learnt....mite b silly 2....
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: Problem with dynamic php include

Post by papa »

Mm I get something before: <p> This is the home page </p>
When I view the page in IE6.

Anything odd in home.php?

Try copy paste the code into notepad and clean it.
Blackframe
Forum Newbie
Posts: 3
Joined: Thu Dec 17, 2009 4:28 am

Re: Problem with dynamic php include

Post by Blackframe »

Thanks papa. Problem solved. I just had to clean it by copying and pasting again the code in notepad.

Sweet!!..

Thanks
:D
Post Reply