Page 1 of 1

Problem with dynamic php include -- SOLVED --

Posted: Thu Dec 17, 2009 4:43 am
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!!!

Re: Problem with dynamic php include

Posted: Thu Dec 17, 2009 6:57 am
by papa
Dunno

Code: Select all

 
$include = $page.'.php';
 
or
 
include (trim($include));
 
 

Re: Problem with dynamic php include

Posted: Thu Dec 17, 2009 7:41 am
by Blackframe
Tried that but still the space remains. :-((((
... any other thoughts will be much appreciated.

Re: Problem with dynamic php include

Posted: Fri Dec 18, 2009 7:03 am
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....

Re: Problem with dynamic php include

Posted: Fri Dec 18, 2009 7:09 am
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.

Re: Problem with dynamic php include

Posted: Tue Dec 22, 2009 8:11 am
by Blackframe
Thanks papa. Problem solved. I just had to clean it by copying and pasting again the code in notepad.

Sweet!!..

Thanks
:D