Most odd thing ive ever seen

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SirChick
Forum Contributor
Posts: 125
Joined: Tue Jul 31, 2007 11:55 am

Most odd thing ive ever seen

Post by SirChick »

Ok this is most weird... my pages are all fine but i load up one of my pages and some how out of know real explanation this '£' symbol echos like '�'

Even my include for that page which echo's a £ also shows '�'.

But if i go to any other page again it goes back to '£'.

Its most strange, what sort of thing can cause this cos I don't know where to begin looking for fixing this issue... no errors occur and the scripts still work as per usual.

Any one had this problem before?
**Adittional info - its only doing it on my firefox**
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

It's a character encoding problem. The page is being served in one character set, but the data is in a different one. It usually happens because someone has inputed data with a browser set to force pages to load in a strange encoding, or if they've pasted from Word or something.

There are two possible fixes:

1. Make sure your entire tool chain is using the correct character encoding, all your data is saving in the correct character set, and your database interaction and display is in the same character set.

or

2. Use £ instead of £. str_replace them, or REPLACE() (the MySQL string function, not the 'insert/replace' syntax) in the SQL, or use htmlentities() if it'll work on the data (if it's in a multibyte encoding then it might not).
SirChick
Forum Contributor
Posts: 125
Joined: Tue Jul 31, 2007 11:55 am

Post by SirChick »

Ok im confused cos i didnt change any setttings and i wldnt know how to change encoding etc all i have is:

Echo '£ ';Echo$Money;

its physically hard coded so user input is not an issue.
all your data is saving in the correct character set, and your database interaction and display is in the same character set.
wouldn't this only count if it was variable containing the single char of £ ?


I restarted my pc and it worked =/ not sure what i did though lol
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Sounds like Firefox had decided to use a different character encoding rather than autodetecting it. It does that sometimes.
SirChick
Forum Contributor
Posts: 125
Joined: Tue Jul 31, 2007 11:55 am

Post by SirChick »

Oh ok.. so probably just firefox loaded a bit dodgy =/
Post Reply