Forum Moderators: coopster
<?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.
Does anybody know what is causing this gap and how it can be fixed / eliminated?
Please let me know
Thank you
When I include something static it lines up ok, but as soon as I set it back to include the rotator.php I get the 25px gap.
Another thing that 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 ;-(
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.
Thank you
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.
I used Expression Web 2 and have the BOM features turned off.
How can this be fixed?
<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 also tried to save these files as txt files with utf-8 encoding, but it doesn't make a difference as far as the gap and the upside down question mark once they are pulled in through the rotator.php
Every time I'd run the page it would return errors for invalid XML. It took me a couple hours hunting through every line of code before I realized it was the include. It was adding space at the top of the document and therefore rendering the XML invalid for the "junk before" reason.
I searched online but never did find a good explanation of this, though plenty of other people had experienced it. I ended up having to hard code the DB connect script rather than include it, and the page works fine. Not an ideal solution though!