scottfennell Posted March 7, 2009 Share Posted March 7, 2009 I am trying to php require() a header, footer, and sidebars for www.sacosolarstore.com . When I have tried to do this, I get wierd margins above the elements when they appear in the page that requires them, except for the footer, which displays correctly. Here is another version of the home page, but with php require()s for the elements that repeat on multiple pages. http://www.sacosolarstore.com/index1.php I have tried zeroing out every margin and padding I could think of on my style sheet. Any ideas? Scott (novice) Quote Link to comment https://forums.phpfreaks.com/topic/148332-anyone-else-get-wierd-margins-on-top-of-elements-that-you-php-require/ Share on other sites More sharing options...
Philip Posted March 7, 2009 Share Posted March 7, 2009 The only thing I can see is when viewing the source an unwanted character appears... see screenie for details. Check your script to make sure there aren't any extra spaces outside your <?php ?> tags [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/148332-anyone-else-get-wierd-margins-on-top-of-elements-that-you-php-require/#findComment-778757 Share on other sites More sharing options...
scottfennell Posted March 12, 2009 Author Share Posted March 12, 2009 Thank you for the attempt, but that does not seem to solve it. Although I am not getting the unwanted character anymore, now that I have removed all extra spaces outside of the tags. Another thing I have noticed that will maybe help diagnose: When I require() the <div> tags, I get extra margin on top. When I leave the <div> tags in the original layout and just require() the contents of the div, I get extra padding instead. I'm kind of stumped. Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/148332-anyone-else-get-wierd-margins-on-top-of-elements-that-you-php-require/#findComment-783063 Share on other sites More sharing options...
PFMaBiSmAd Posted March 12, 2009 Share Posted March 12, 2009 There is something in your code or files causing the symptom, because a require() statement only literally inserts the code in the required file at the point where the require() statement is placed. Post one of your require() statements and show about five lines of code before the require() statement. Post the whole content of the corresponding required file. Quote Link to comment https://forums.phpfreaks.com/topic/148332-anyone-else-get-wierd-margins-on-top-of-elements-that-you-php-require/#findComment-783087 Share on other sites More sharing options...
scottfennell Posted March 12, 2009 Author Share Posted March 12, 2009 Here is about 5 lines of code and my first require() statement: <link rel="stylesheet" type="text/css" href="style.css" media="screen"/> </head> <body> <div id="wrap"> <?php require('header.htm'); ?> Here is the file being require()d <div id="header"> <ul id ="contactinfo"> <li>The Saco Solar Store</li> <li>743 Portland Road (Route 1)</li> <li>Saco, ME 04072</li> <li>(207)283-1413</li> <li>Open: Mon-Fri: 9-5, Sat: 10-2</li> <li><a href="mailto:saco@usasolarstore.com">Email</a></li> </ul> </div> Something else I noticed: While tinkering, I tried including the div tags in both the original layout and in the require()d file. However, I forgot to include closing quotation marks in the div id in the original layout while I was tinkering with it. The result was that it closed my wrap div, but I also was not getting the wierd margin or padding! Quote Link to comment https://forums.phpfreaks.com/topic/148332-anyone-else-get-wierd-margins-on-top-of-elements-that-you-php-require/#findComment-783102 Share on other sites More sharing options...
scottfennell Posted March 13, 2009 Author Share Posted March 13, 2009 If it helps, I have also noticed that the error does not occur when the require()d element contains only text and no html tags. I am running php version 4.4.8. Quote Link to comment https://forums.phpfreaks.com/topic/148332-anyone-else-get-wierd-margins-on-top-of-elements-that-you-php-require/#findComment-783981 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.