Jump to content

Recommended Posts

Hi, I found this script:

<?php

$pages = array('xyz.html','123.html');

$i = rand(0, count($pages) - 1);

include($pages[$i]);

?>

 

which I have saved as rotate.php

The script is supposed to enable rotating between the content of two pages on my home page.

 

When I add it via

<!--#include virtual="rotate.php" -->

on my home page it works fine, but it causes a gap of at least 25px between the header above and where the script generated content starts.

 

When I replace the include with something else it lines up just fine. I also have other php includes on the page that line up.

 

Next thing I tried is to put a negative margin in to move it up, which works fine in IE8, FF and Safari, but when I look at it in Opera it's now 25px to high ;-(

 

So I looked for "php include gap" on the web and ran into some sites that talk about BOM being an issue.

 

I also noticed that when I look at my page with the included rotator.php on lynx it shows an upside down question mark where the gap is.

 

Is there anything in the rotator script I posted above that could be causing this? Btw, in case it matters, the doc is xhtml strict and utf-8 in Expression Web 2 with BOM turned off.

 

Thank you

 

Link to comment
https://forums.phpfreaks.com/topic/162267-php-include-causes-unwanted-gap/
Share on other sites

just simple paragraphs like the one below:

 

<p><img src="images/alero.jpg" height="120" width="180" alt="" /><br />Oldsmobile Alero<br />$4,000<br /><a href="#">more info</a></p>

 

I have also saved xyz and 123 as .txt instead of .html to see if it makes a difference, but no success either

index.html:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>test</title>

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

<style type="text/css">

body { margin:0px; background:#000000; text-align:left; font-family:helvetica,arial,sans-serif; font-size:10pt; color:#ffffff; text-decoration: none; }

#wrapper {text-align:left; margin:0px auto; padding:0px; border:0; width:966px; }

#lco { float:left; margin-left:18px; width:190px; }

#cco { float:left; margin-left:10px; width:530px; }

#rco { float:right; margin-right:18px; width:190px; }

</style>

</head>

<body>

<div id="wrapper">

<div id="con">

<div id="lco"><!--#include virtual="rotator.php" --></div>

<div id="cco">center</div>

<div id="rco">right</div>

</div>

</div>

</body>

</html>

 

rotator.php:

 

<?php

$pages = array('123.html','xyz.html');

$i = rand(0, count($pages) - 1);

include($pages[$i]);

?>

 

123.html:

 

<div>Oldsmobile Alero<br />$4,000<br /><a href="#">more info</a></div>

 

xyz.html:

 

<div>Buick Sabre<br />$5,000<br /><a href="#">more info</a></div>

Please supply us with a link to the actual page.

 

You could use a redirecting url (e.g. tinyurl.com) to protect your site's domain from future posters. Simply remove the tinyurl once the problem has been solved. You can even rename the file on your site while we're looking for a solution.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.