Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ General Web Design _ HTML Letter Error

Posted by: Needler Aug 9 2011, 11:23 PM

Hello All,

My name is Josh, I have a question about some simple HTML that I would like to receive some help with.

------

Me and a friend run a Counter-strike hosting company, and we have created the following HTML code, however there is a error, and I cannot figure out the problem.

If you look at the address below,
http://184.154.138.58/test3.php?ip=184.154.138.58&port=36965

You can see that on the third line down, there is a table, set with the server name.

The server name is

cZ» Sparta

I don't know the error, but the server name should actually be,

cZ» Sparta

Somehow a random "A" letter is inserted. How might I fix this?

I would appreciate any help. Thx.

Posted by: Darin McGrew Aug 10 2011, 12:13 AM

The file appears to use UTF-8 character encoding, but your server is sending it as

Content-Type: text/html

rather than as

Content-Type: text/html; charset=UTF-8

so the browser has to guess what character encoding to use.

Posted by: Brian Chandler Aug 10 2011, 12:16 AM

It isn't a proper html document, since it starts "<table border="1"><tr><td>IP</td><td>184.154.138.58</td></tr><tr><td>Port</td><td>36965</td></tr><tr><td>Name</td><td>cZ» Sparta..."

Your program needs to output the rest of the document, starting with doctype, including <html>, <head>, <body>, etc.

In the html document you should specify what encoding you are using; the character problem is almost certainly a confusion of encodings. We can't find the problem (if there is one) in the php program without seeing it...

HTH

Posted by: Needler Aug 10 2011, 06:21 PM

So, I need to Format and include <html>, <head>, <body>, etc.


And how might I change it from Content-Type: text/html

to


Content-Type: text/html; charset=UTF-8

Posted by: Darin McGrew Aug 10 2011, 06:35 PM

You don't add the charset in your HTML. You add it by configuring the server. The details vary depending on the server, but could be as easy as adding the line

CODE
AddDefaultCharset utf-8
to your .htaccess file (assuming you're using Apache).

Posted by: Needler Aug 10 2011, 09:33 PM

Okay, so I have added the charset to the .htaccess file, rebooted the server, restarted Apache and nothing seems to have changed. Is there any other way i could fix this? or Is it just my bad luck.

dry.gif

Posted by: Darin McGrew Aug 11 2011, 12:47 AM

The charset (or lack thereof) hasn't changed:

CODE
$ lynx -dump -head 'http://184.154.138.58/test3.php?ip=184.154.138.58&port=36965'
HTTP/1.1 200 OK
Date: Thu, 11 Aug 2011 00:50:02 GMT
Server: Apache/2.2.16 (Debian) PHP/5.3.3-7+squeeze3 with Suhosin-Patch
X-Powered-By: PHP/5.3.3-7+squeeze3
Vary: Accept-Encoding
Connection: close
Content-Type: text/html

Posted by: Brian Chandler Aug 11 2011, 03:05 AM

QUOTE(Needler @ Aug 11 2011, 11:33 AM) *

Okay, so I have added the charset to the .htaccess file, rebooted the server, restarted Apache and nothing seems to have changed. Is there any other way i could fix this? or Is it just my bad luck.

dry.gif


Well, if you make the php program output a proper html file (almost all of this will just be a constant string at the beginning and end), then you can at least output a meta tag with the content type. In practice this will tell browsers which character set to us. (As I recall, the original html specification is incoherent hereabouts.)

Posted by: Darin McGrew Aug 11 2011, 12:04 PM

Oops... I forgot about PHP. The PHP file will need to include the following at the beginning:

CODE
header( 'Content-type: text/html; charset=utf-8' );

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)