Jump to content

Recommended Posts

Hi,

I thought I was finished with my site and uploaded it all, but I seem to have unwanted lines where my php includes are. I have two includes, one for the header, and one for the footer. I've tried to find a solution but can't seem to find one. I don't know much about coding, but I followed what was in certain tutorials I could find. My website is: www.anjalirao.net, don't mind the warnings on the blog and Talk Asia pages, I still have to upload my CMS. You can see a space right in the beginning and above my little footer, but if you look at the code, it's not suppose to be there? Maybe I'm missing something. Please help!

 

This is one of my pages and how i included the php:

 

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

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

<head>

<link href="style.css" rel="stylesheet" type="text/css" />

<link href="templates.css" rel="stylesheet" type="text/css" />

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

<meta name="description" content="Anjali Rao pictures, videos, news, Talk Asia, biography, links, and more." />

<title>AnjaliRao.net - Everything about Anjali Rao</title>

</head>

 

<body>

 

  <div id="wrapper">

 

<?php $current = 1; include("header.php"); ?>

 

  <div id="space20h"></div>

 

  <div class="space3h10w"></div>

  <div id="titleline1"></div>

  <div class="space3h10w"></div>

  <div class="clearleft"></div>

 

  <div id="title">Blog</div>

 

  <div class="space3h10w"></div>

  <div id="titleline2"></div>

  <div class="space3h10w"></div>

  <div class="clearleft"></div>

 

  <div id="contentarea">

 

<?php

$cat[] = 'Blog';

$nppage = '30';

$template = 'Blog';

include 'news/index.php';

?>

 

  </div>

 

<?php include("footer.php"); ?>

 

  </div>

 

</body>

</html>

 

 

And this is my little footer.php:

 

  <div class="space2h10w"></div>

  <div id="footerline"></div>

  <div class="space2h10w"></div>

  <div class="clearleft"></div>

 

  <div id="footer">Please note that I'm not affiliated with Anjali Rao or CNN in any way.</div>

 

 

Why do they make those extra lines?

Link to comment
https://forums.phpfreaks.com/topic/238855-php-includes-add-unwanted-line-s/
Share on other sites

from what I can see the extra lines are the blank lines you have in your code already, have an empty line above and below your header and your footer inserts, so this will be a blank line above and below the html of those includes when the page generates the html, remove those lines and your code should remove them, the only other thing that will modify it is the css styles you have applied to the div tags, but I would remove any blank lines you dont want in your code first.

could it not be that you have a margin or padding on the footer css? (just a suggestion, 'cause I can't see the css files) .

 

Just as a note, I noticed you use:

 

include 'news/index.php'; // single quotes, no parentheses

and then

include("footer.php"); // parentheses and double quotes.

 

not that it's harmful in any way, but why the 2 different styles of programming?

from what I can see the extra lines are the blank lines you have in your code already, have an empty line above and below your header and your footer inserts, so this will be a blank line above and below the html of those includes when the page generates the html, remove those lines and your code should remove them, the only other thing that will modify it is the css styles you have applied to the div tags, but I would remove any blank lines you dont want in your code first.

 

Hi dragon_sa, I removed the lines like you said but it still shows the same spaces. The only thing thats different now is that I don't have the spaces in my coding.

 

could it not be that you have a margin or padding on the footer css? (just a suggestion, 'cause I can't see the css files) .

 

Just as a note, I noticed you use:

 

include 'news/index.php'; // single quotes, no parentheses

and then

include("footer.php"); // parentheses and double quotes.

 

not that it's harmful in any way, but why the 2 different styles of programming?

 

Hi WebStyles, yes I do have a margin-bottom: 20px; on my footer, but that does not explain the blank line above it or the one above my header. Ehm the 2 different styles of programming, I wasn't even aware they were two different styles of programming. Like I said, I used tutorials and apparantly one uses it that way and the CMS the other way. (I copy pasted it) But thanks for pointing it out. I can make it neater. :P

 

Hi gabriels,

 

I am sure, you have problem with path, If you face problem in relative path then give absolute path.

 

Hi chintansshah. Path? You mean directory paths in the php like include("header.php");? Or do you mean the position style relative and absolute? The only thing i have relative is the header, because I needed to position the google search in it with absolute. But I don't see how that could cause spaces?

 

Thank you all very much for you help it is highly appreciated!

Ok, I've solved the problem. I red that having a bom in your php files could cause problems, and I also found out that notepad puts them in automatically. So I downloaded notepad++ and converted my php file, and voila no more spaces. I'm sorry to have wasted your time. Thanks for the help.

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.