1

Hello from a complete newbie to PHP5.

I created a header file (html) which contains navigation links.

In another page (index.php) I put an include in the body of the page.

The index page has a link to a css file which styles the navigation links in the include file.

When I view the page, the part where the include is made contains garbled characters (well mostly diamond chars with ? inside).

If I replace the header file with a simplified one with only one div block it displays fine. So I suspect that the include file does not like the style sheet references?!?

I would appreciate it if someone could shed some light on this.

Many thanks,

KS

<div id="header">
<div id="menu">
  <ul id="nav-one" class="nav">
    <li>
      <a href="#">About Us</a>
      <ul>
        <li><a href="about-wcjja.html">About WCJJA</a></li>
        <li><a href="about-wing-chun.html">Wing Chun</a></li>
        <li><a href="history-of-wing-chun.html">History</a></li>
        <li><a href="new.html">What's New</a></li>
        <li><a href="wing-chun-links.html">Links</a></li>
      </ul>
    </li>
    <li>
      <a href="#">Instructors</a>
      <ul>
        <li><a href="marvon-wilkinson.html">Marvon Wilkinson</a></li>
        <li><a href="lineage.html">Lineage</a></li>
      </ul>
    </li>
    <li>
      <a href="#">Classes</a>
      <ul>
        <li><a href="wing-chun-classes.html">Wing Chun</a></li>
        <li><a href="womens-self-defense.html">Women's Self Defense</a></li>
        <li><a href="workshops.html">Seminars &amp; Workshops</a></li>
      </ul>
    </li>
    <li>
      <a href="#item2">Media</a>
      <ul>
        <li><a href="gallery.html">Gallery</a></li>
        <li><a href="videos.html">Video</a></li>
        <li><a href="more-wc.html">More Wing Chun</a></li>
      </ul>
    </li>
    <li>
      <a href="#">Contact Us</a>
      <ul>
        <li><a href="email-us.html">Email Us</a></li>
        <li><a href="schools.html">School Locations</a></li>
        <li><a href="bookmark-us.html">Bookmark us</a></li>
        <li><a href="copyright.html">Copyright</a></li>
      </ul>
    </li>
  </ul>
</div>
</div>
3
  • 1
    I'd stay it's more likely the encoding of your include file. Commented May 20, 2011 at 21:51
  • There's almost certainly something wrong with your encoding. Can you edit your question to include the code you are using in the header? Commented May 20, 2011 at 21:52
  • This could also be an issue not with the included file itself, but with the declared content-type in the final HTML output. Commented May 20, 2011 at 21:53

4 Answers 4

2

Sounds like a character encoding issue, what format are your files in? I´d recommend putting everything in utf8

Sign up to request clarification or add additional context in comments.

3 Comments

I think the owner of site is using some char enc that displays chinese. In my css file I have put a declaration for utf-8 and also in my index php file. I have not put one in the include file which consists of divs. Since there is no html or head tag in there I am not sure how to declare the encoding in there. Any ideas? thx.
I think the header file is not having the correct encoding as you guys mentioned. Problem is, how do I declare it's encoding without a header tag? Interesting the IE is the only browser ignores the encoding and renders fine (that could be a bad thing too i guess!).
I don´t know what system you're on and what IDE you are using, but if you are on windows, you can use for example Notepad++ and change the encoding to utf8 from the menu.
1

Ensure your content-type header is correct.

You can try:

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

(delete any other content-type headers that may exist)

2 Comments

No joy :( there are no other headers, only several divs.
You can view the site here btw - its not top secret :) wcjja.com/design%20fix/index2.php
1

The problem is that there are 2 different encodings in the source, and a page may only declare one encoding.

When I view source in Firefox on the header section this is what I see:

��<�d�i�v� �i�d�=�"�h�e�a�d�e�r�"�>�

The format of the header file is probably some double-byte format, maybe UTF-16 maybe something else, but the rest of the page is in UTF-8.

Use a text editor that allows you to choose the encoding of the (header) file and save that file as UTF-8 and that should fix your problem.

Comments

-1

Just put this code in your .htaccess, you will use utf-8 always anyway.

.htaccess

AddType text/html;charset=utf-8 .html

OR

btw. if u should use XHTML, u would not get an utf-8 problem. set your doctype as xhtml and transitional, it will be utf-8 for all pages automatically.

 <?php header("Content-Type: text/html; charset=utf-8"); ?>
 <!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">

these tags will save you anytime.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.