Jump to content

[SOLVED] php include - funny output


MartinHansell

Recommended Posts

Hi,  I am so new it's fantastic!  Trying to use a simple list in a menu.php file as an include in all my pages.  This is the code that I am using:

 

<?php include("scripts/menu4.php");?>

 

The file is included ok, but there is an added line with funny characters on it like this "".  It renders differently in IE 7 and Firefox.  IE7 creates the added line in the same content box kind half way up above the actual first line, whereas Firefox puts it above it's parent box.  Not really sure what's causing it - any ideas???

 

I have loads of questions about the "best" way to produce menus/nav in web pages too.... My gut tells me that MySQL with PHP is a good way to go... if you have time can you point me in the right direction..

 

Many thanks

Martin

Link to comment
Share on other sites

It depends.  I would guess menu php based on what you have said.  To really figure it out, make two combinations: one with a simple html and menu.php, and one with a simple header and the regular html file.  By what shows up, that will narrow down the problem for you.  Then, post some code up here!

Link to comment
Share on other sites

Hi,

 

Like I said - very new!!  t really sure what you mean by a header page?

 

Here is my html code for a really slimmed down version of my page.  I've tried it with and without the doctype header, but the css goes squiffy.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" hhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>

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

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

</head>

 

<body>

    <div id="leftcontent">

<?php include("scripts/leftmenu1.php");?>

</div><!--close leftcontent-->

 

    <div id="centercontent">

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

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

</div><!--close centercontent-->

 

<div id="rightcontent">

  <?php include("scripts/rightmenu1.php");?>

</div><!--close rightcontent-->

 

</body>

</html>

 

Here is the leftmenu1.php code:

 

<ul>

<li><a href="http://hansellfamily.homeip.net/index.php" title="Home">Home</a></li>

<li><a href="news/index.php"  title="Keep up with the times">News</a></li>

<li><a href="about/index.php"  title="Just who are the Hansell Family?">About us</a></li>

<li><a href="gallery2/main.php?g2_itemId=81" title="A birds eye view of the family">Photos</a></li>

<li><a href="blog/index.php"  title="So what's a Blog?">Blogged up</a></li>

<li><a href="language/index.php"  title="Languages">Languages</a></li>

<li><a href="education/index.php"  title="Home education with a differnce">Educate me</a></li>

<li><a href="culture/index.php"  title="The impact of culture">Culture vulture</a></li>

</ul>

 

The other includes are exactly the same format just with either an <h1 /> or <p /> tag in them and some text.

 

Even with this very simple structure the dodgy characters are still appearing...

 

http://hansellfamily.homeip.net/indextest2.php  (this is the page with the output....)

 

Thanks a lot for taking the time!

Martin

 

ps - i am now going to try it without any css and see what happens.

Link to comment
Share on other sites

hoho - that's simple.

 

I've now stripped it down step by step until there is just one line on the html page (that is  the php include statement) without even the <html /> or <body /> elements (the page is still rendering) and one line of text in the include file, with all sorts of .inc, .wink, and .stink extensions... still the same handshake when the page prints the line of text.

 

Could it be in the setup of my php.ini file? 

 

Cheers

 

ps - would have pointed you to o'reilly too on the apache stuff - hope you find what you are looking for!

Link to comment
Share on other sites

Is that a question or a statement?  Right now, don't worry about if the page works/looks like you want.  Worry about finding the error.  So besides including the php header, the html should just be this:

 

<html>

<head><title>test</title></head>

<body>

This is just a test!

</body>

</html>

 

If you don't get the error, then it is not the php header.  See what I mean?

Link to comment
Share on other sites

I have copy/pasted your sample code plus my php include statement into the html page and it's total contents now looks like this:

 

<html>

<head><title>test</title></head>

<body>

This is just a test!<br/>

 

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

 

</body>

</html>

 

The sole contents of the php file are:

 

This is the 1st include TEST file of the page

 

... and there is absolutely nothing in the file except this text string - is this correct?

 

url again :  http://hansellfamily.homeip.net/indextest3.php

 

cheers

Martin

Link to comment
Share on other sites

That seems like an odd place for an include.  BUT, no, the php file should say

 

<?PHP

 

print "This is just a test";

 

?>

 

In fact, if that does not work, try just putting this php statement in there by itself without including the file.  See if that works.

Link to comment
Share on other sites

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.