Margins increase when using include()

Discussion in 'PHP' started by dangasin, Jul 1, 2009.

  1. #1
    I just started using php today and I came accross an issue when I include my navigation php file into the homepage. A margin appears at the top of the page with strange characters. When I changed the charset, the margin is still there but the characters are gone. Anyone know what the problem is? Let me know if I need to give a link to the pages so they can be uploaded. Thanks.
     
    dangasin, Jul 1, 2009 IP
  2. livedating

    livedating Active Member

    Messages:
    161
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    83
    #2
    Could you please cut and paste here your code?

    Maybe this margin is cased by css or html attributes?

    Make sure you do not have spaces or newlines chars before you call include, for example:

    
      text1
      <? include('file.php');?>
      text2
    
    Code (markup):
    and

    
    text1<? include('file.php');?>text2
    
    Code (markup):
     
    livedating, Jul 2, 2009 IP
  3. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #3
    Yes we need to see the codes its a html thing for sure
     
    Bohra, Jul 2, 2009 IP
  4. dangasin

    dangasin Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Maybe it has to do with the fact that I have the <tr> tags unincluded? Also I didn't even make a css file for it yet...it was just a temporary attempt at getting the php code to work. I am a complete novice at php. Here is the code for it though.

    
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="margin:0px;background-image:url('images/background.gif');background-repeat:repeat-x;">
    
    
    
    <?php include("http://www.gobustbookies.com/temp/top.html");?>
    
    		
    		<tr>
    			<td colspan="10">
    			<img src="images/templogo_20.gif" width="892" height="271" alt=""></td>
    	    </tr>
    	    
    <?php include("http://www.gobustbookies.com/temp/bottom.html");?>
    </body>
    </html>
    
    
    
    Code (markup):
    The included html files are on the server...but they are just the rest of the table. Lemme know what you get. I appreciate the help.
     
    dangasin, Jul 2, 2009 IP
  5. mioot

    mioot Peon

    Messages:
    169
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Could you post the url for this page?
     
    mioot, Jul 2, 2009 IP
  6. dangasin

    dangasin Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
  7. www.amagit.com

    www.amagit.com Peon

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You had 2 bizarre characters in your file. These characters pushed the table down a notch. Here is a copy of your source with the characters removed. Copy the source over the original source in the file:

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="margin:0px;background-image:url('http://www.gobustbookies.com/temp/images/background.gif');background-repeat:repeat-x;">
     
     
     
    
     
    	<table id="Table_01" border="0" cellpadding="0" cellspacing="0" align="center">
    	<tr>
    		<td colspan="13">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_01.gif" width="1000" height="11" alt=""></td>
    	</tr>
    	<tr>
    		<td rowspan="8">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_02.gif" width="37" height="689" alt=""></td>
    		<td colspan="3" rowspan="3">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_03.gif" width="229" height="161" alt=""></td>
    		<td colspan="9">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_04.gif" width="734" height="53" alt=""></td>
    	</tr>
    	<tr>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/templogo_05.gif" width="102" height="51" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/templogo_06.gif" width="103" height="51" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/templogo_07.gif" width="158" height="51" alt=""></td>
    		<td colspan="2">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_08.gif" width="134" height="51" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/templogo_09.gif" width="88" height="51" alt=""></td>
    		<td colspan="2">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_10.gif" width="124" height="51" alt=""></td>
    		<td rowspan="7">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_11.gif" width="25" height="636" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="8">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_12.gif" width="709" height="57" alt=""></td>
    	</tr>
    	<tr>
    		<td rowspan="5">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_13.gif" width="46" height="528" alt=""></td>
    		<td colspan="6">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_14.gif" width="593" height="114" alt=""></td>
    		<td colspan="3" rowspan="2">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_15.gif" width="178" height="191" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/templogo_16.gif" width="121" height="114" alt=""></td>
    	</tr>
    	<tr>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/templogo_17.gif" width="3" height="77" alt=""></td>
    		<td colspan="5">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_18.gif" width="590" height="77" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/templogo_19.gif" width="121" height="77" alt=""></td>
    	</tr>
     
    		
    		<tr>
    			<td colspan="10">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_20.gif" width="892" height="271" alt=""></td>
    	    </tr>
    	    
    
     
    <tr>
    		<td rowspan="2">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_21.gif" width="3" height="66" alt=""></td>
    		<td colspan="5">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_22.gif" width="590" height="3" alt=""></td>
    		<td colspan="3">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_23.gif" width="178" height="3" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/templogo_24.gif" width="121" height="3" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="9">
    			<img src="http://www.gobustbookies.com/temp/images/templogo_25.gif" width="889" height="63" alt=""></td>
    	</tr>
    	<tr>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="37" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="46" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="3" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="180" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="102" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="103" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="158" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="47" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="87" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="88" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="3" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="121" height="1" alt=""></td>
    		<td>
    			<img src="http://www.gobustbookies.com/temp/images/spacer.gif" width="25" height="1" alt=""></td>
    	</tr>
    </table>
    </body>
    </html>
    Code (markup):
     
    www.amagit.com, Jul 2, 2009 IP
  8. www.amagit.com

    www.amagit.com Peon

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Ignore the code above.
    Rather, replace top.html with:
    
     
    	<table id="Table_01" border="0" cellpadding="0" cellspacing="0" align="center">
    	<tr>
    		<td colspan="13">
    			<img src="images/templogo_01.gif" width="1000" height="11" alt=""></td>
    	</tr>
    	<tr>
    		<td rowspan="8">
    			<img src="images/templogo_02.gif" width="37" height="689" alt=""></td>
    		<td colspan="3" rowspan="3">
    			<img src="images/templogo_03.gif" width="229" height="161" alt=""></td>
    		<td colspan="9">
    			<img src="images/templogo_04.gif" width="734" height="53" alt=""></td>
    	</tr>
    	<tr>
    		<td>
    			<img src="images/templogo_05.gif" width="102" height="51" alt=""></td>
    		<td>
    			<img src="images/templogo_06.gif" width="103" height="51" alt=""></td>
    		<td>
    			<img src="images/templogo_07.gif" width="158" height="51" alt=""></td>
    		<td colspan="2">
    			<img src="images/templogo_08.gif" width="134" height="51" alt=""></td>
    		<td>
    			<img src="images/templogo_09.gif" width="88" height="51" alt=""></td>
    		<td colspan="2">
    			<img src="images/templogo_10.gif" width="124" height="51" alt=""></td>
    		<td rowspan="7">
    			<img src="images/templogo_11.gif" width="25" height="636" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="8">
    			<img src="images/templogo_12.gif" width="709" height="57" alt=""></td>
    	</tr>
    	<tr>
    		<td rowspan="5">
    			<img src="images/templogo_13.gif" width="46" height="528" alt=""></td>
    		<td colspan="6">
    			<img src="images/templogo_14.gif" width="593" height="114" alt=""></td>
    		<td colspan="3" rowspan="2">
    			<img src="images/templogo_15.gif" width="178" height="191" alt=""></td>
    		<td>
    			<img src="images/templogo_16.gif" width="121" height="114" alt=""></td>
    	</tr>
    	<tr>
    		<td>
    			<img src="images/templogo_17.gif" width="3" height="77" alt=""></td>
    		<td colspan="5">
    			<img src="images/templogo_18.gif" width="590" height="77" alt=""></td>
    		<td>
    			<img src="images/templogo_19.gif" width="121" height="77" alt=""></td>
    	</tr>
    
    Code (markup):
    and bottom.html with:
    
    <tr>
    		<td rowspan="2">
    			<img src="images/templogo_21.gif" width="3" height="66" alt=""></td>
    		<td colspan="5">
    			<img src="images/templogo_22.gif" width="590" height="3" alt=""></td>
    		<td colspan="3">
    			<img src="images/templogo_23.gif" width="178" height="3" alt=""></td>
    		<td>
    			<img src="images/templogo_24.gif" width="121" height="3" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="9">
    			<img src="images/templogo_25.gif" width="889" height="63" alt=""></td>
    	</tr>
    	<tr>
    		<td>
    			<img src="images/spacer.gif" width="37" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="46" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="3" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="180" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="102" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="103" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="158" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="47" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="87" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="88" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="3" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="121" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="25" height="1" alt=""></td>
    	</tr>
    </table></body>
    
    Code (markup):
    and templogo.php with:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="margin:0px;background-image:url('images/background.gif');background-repeat:repeat-x;">
    
    
    
    <?php include("http://www.gobustbookies.com/temp/top.html");?>
    
    		
    		<tr>
    			<td colspan="10">
    			<img src="images/templogo_20.gif" width="892" height="271" alt=""></td>
    	    </tr>
    	    
    <?php include("http://www.gobustbookies.com/temp/bottom.html");?>
    </body>
    </html>
    Code (markup):
     
    www.amagit.com, Jul 2, 2009 IP
  9. dangasin

    dangasin Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I am still getting the same margin error. I do not know why the characters are appearing/ why the margin is still there. Any more ideas?
     
    dangasin, Jul 2, 2009 IP
  10. www.amagit.com

    www.amagit.com Peon

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    The characters are in the white space of the files (you must have inserted them somehow. They are undisplayable characters so you can't see them. Delete some of the extra white space.
     
    www.amagit.com, Jul 2, 2009 IP
  11. www.amagit.com

    www.amagit.com Peon

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Here is a picture of the page as a whole after the top and bottom are included. I marked where the characters are. Delete the white space (what appears to be white space) around those areas in the separate files. Look for (BAD CHAR HERE) in the file twice and (A COUPLE BAD CHARS HERE) once.

    
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="margin:0px;background-image:url('images/background.gif');background-repeat:repeat-x;">
     
     
     
    (BAD CHAR HERE)
    	<table id="Table_01" border="0" cellpadding="0" cellspacing="0" align="center">
    	<tr>
    		<td colspan="13">
    			<img src="images/templogo_01.gif" width="1000" height="11" alt=""></td>
    	</tr>
    	<tr>
    		<td rowspan="8">
    			<img src="images/templogo_02.gif" width="37" height="689" alt=""></td>
    		<td colspan="3" rowspan="3">
    			<img src="images/templogo_03.gif" width="229" height="161" alt=""></td>
    		<td colspan="9">
    			<img src="images/templogo_04.gif" width="734" height="53" alt=""></td>
    	</tr>
    	<tr>
    		<td>
    			<img src="images/templogo_05.gif" width="102" height="51" alt=""></td>
    		<td>
    			<img src="images/templogo_06.gif" width="103" height="51" alt=""></td>
    		<td>
    			<img src="images/templogo_07.gif" width="158" height="51" alt=""></td>
    		<td colspan="2">
    			<img src="images/templogo_08.gif" width="134" height="51" alt=""></td>
    		<td>
    			<img src="images/templogo_09.gif" width="88" height="51" alt=""></td>
    		<td colspan="2">
    			<img src="images/templogo_10.gif" width="124" height="51" alt=""></td>
    		<td rowspan="7">
    			<img src="images/templogo_11.gif" width="25" height="636" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="8">
    			<img src="images/templogo_12.gif" width="709" height="57" alt=""></td>
    	</tr>
    	<tr>
    		<td rowspan="5">
    			<img src="images/templogo_13.gif" width="46" height="528" alt=""></td>
    		<td colspan="6">
    			<img src="images/templogo_14.gif" width="593" height="114" alt=""></td>
    		<td colspan="3" rowspan="2">
    			<img src="images/templogo_15.gif" width="178" height="191" alt=""></td>
    		<td>
    			<img src="images/templogo_16.gif" width="121" height="114" alt=""></td>
    	</tr>
    	<tr>
    		<td>
    			<img src="images/templogo_17.gif" width="3" height="77" alt=""></td>
    		<td colspan="5">
    			<img src="images/templogo_18.gif" width="590" height="77" alt=""></td>
    		<td>
    			<img src="images/templogo_19.gif" width="121" height="77" alt=""></td>
    	</tr>
    		
    		<tr>
    			<td colspan="10">
    			<img src="images/templogo_20.gif" width="892" height="271" alt=""></td>
    	    </tr>
    	    
    (BAD CHAR HERE)<tr>
    		<td rowspan="2">
    			<img src="images/templogo_21.gif" width="3" height="66" alt=""></td>
    		<td colspan="5">
    			<img src="images/templogo_22.gif" width="590" height="3" alt=""></td>
    		<td colspan="3">
    			<img src="images/templogo_23.gif" width="178" height="3" alt=""></td>
    		<td>
    			<img src="images/templogo_24.gif" width="121" height="3" alt=""></td>
    	</tr>
    	<tr>
    		<td colspan="9">
    			<img src="images/templogo_25.gif" width="889" height="63" alt=""></td>
    	</tr>
    	<tr>
    		<td>
    			<img src="images/spacer.gif" width="37" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="46" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="3" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="180" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="102" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="103" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="158" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="47" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="87" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="88" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="3" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="121" height="1" alt=""></td>
    		<td>
    			<img src="images/spacer.gif" width="25" height="1" alt=""></td>
    	</tr>
    </table></body></html>(A COUPLE BAD CHARS HERE)
    Code (markup):
     
    www.amagit.com, Jul 2, 2009 IP
  12. dangasin

    dangasin Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    i erased all the extra white space in the coding but its still there. Is it because of the charset?
     
    dangasin, Jul 2, 2009 IP
  13. www.amagit.com

    www.amagit.com Peon

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I have had problems with utf-8 in the past. You could try windows-1252 as the charset. Also, I still see some bizarre characters at the bottom of bottom.html & templogo.php after looking at them online.
     
    www.amagit.com, Jul 2, 2009 IP
  14. www.amagit.com

    www.amagit.com Peon

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #14
    I edited the pages and posted them on my site after changing the image links to point to the pics on your domain. It is working. I used the sources posted above except I changed the img src tags and the background-image link. Take a look:
    http://www.amagit.com/dangasin/templogo.php
     
    www.amagit.com, Jul 2, 2009 IP
  15. dangasin

    dangasin Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Could you possibly post the codes for all three files from your server onto here so I can copy them exactly? I am still getting that margin error. Thanks so much for this help.
     
    dangasin, Jul 2, 2009 IP
  16. dangasin

    dangasin Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Another question for you, is there any files I need outside of those to make php run properly, like an .htaccess type file. All I have on my server are those php files, nothing else. Perhaps that is causing the issue?
     
    dangasin, Jul 2, 2009 IP
  17. www.amagit.com

    www.amagit.com Peon

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #17
    There is no need for any other files. Here are the files from my server. I left the urls as absolutes but you should be able to change them back to relatives without any problems.
     

    Attached Files:

    www.amagit.com, Jul 2, 2009 IP
  18. dangasin

    dangasin Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    thank you so much it works perfectly. Now I just have to just compare it to my other ones to see where i messed up. I don't want to encounter the same problem in the future.
     
    dangasin, Jul 2, 2009 IP