pstar99 Posted June 15, 2009 Share Posted June 15, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/162267-php-include-causes-unwanted-gap/ Share on other sites More sharing options...
rhodesa Posted June 15, 2009 Share Posted June 15, 2009 What is the contents of 'xyz.html' and '123.html'? Quote Link to comment https://forums.phpfreaks.com/topic/162267-php-include-causes-unwanted-gap/#findComment-856405 Share on other sites More sharing options...
pstar99 Posted June 15, 2009 Author Share Posted June 15, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/162267-php-include-causes-unwanted-gap/#findComment-856555 Share on other sites More sharing options...
megaresp Posted June 15, 2009 Share Posted June 15, 2009 How about the CSS? Perhaps there it's adding an extra 25 pixels to the bottom of either a div wrapper, or some other tag? As always in these cases, it helps to see the actual live page. Please supply the URL. Quote Link to comment https://forums.phpfreaks.com/topic/162267-php-include-causes-unwanted-gap/#findComment-856562 Share on other sites More sharing options...
rhodesa Posted June 15, 2009 Share Posted June 15, 2009 yup, a page i can load in my browser would really help try using <DIV> instead of <P>, paragraphs have default bottom margin on them Quote Link to comment https://forums.phpfreaks.com/topic/162267-php-include-causes-unwanted-gap/#findComment-856565 Share on other sites More sharing options...
pstar99 Posted June 16, 2009 Author Share Posted June 16, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/162267-php-include-causes-unwanted-gap/#findComment-856672 Share on other sites More sharing options...
pstar99 Posted June 16, 2009 Author Share Posted June 16, 2009 if you run the above code in IE8, Safari and FF there is a gap between the top left and the include. In Opera it lines up as it is supposed to. ??? Quote Link to comment https://forums.phpfreaks.com/topic/162267-php-include-causes-unwanted-gap/#findComment-856674 Share on other sites More sharing options...
megaresp Posted June 16, 2009 Share Posted June 16, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/162267-php-include-causes-unwanted-gap/#findComment-857341 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.