£ sign from database echoing as £

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
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

£ sign from database echoing as £

Post by impulse() »

The database field type is text but any GBP sign is echoing out as '£'. Do you have any suggestions as to why?

Regards,
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: £ sign from database echoing as £

Post by aceconcepts »

Try using £ in it's place.

Also make sure your meta content-type charset is correct.
Last edited by aceconcepts on Wed Jan 16, 2008 8:45 am, edited 1 time in total.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: £ sign from database echoing as £

Post by Kieran Huggins »

You also might want to be using the Unicode (utf-8) charset - there are several ways to define this: a header(), a <meta> tag... I use both to be safe.
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Re: £ sign from database echoing as £

Post by impulse() »

Aceconcepts - That worked fine, I used str_replace() to do the work but that seems like a dirty way of doing it.

Keiran - Does the following look good:

In

Code: Select all

 
header('Content-Type: text/html; charset=utf-8');
<META HTTP-EQUIV="name" CONTENT="UTF-8">
 
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: £ sign from database echoing as £

Post by Kieran Huggins »

Not quite...

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Check out http://tlt.psu.edu/suggestions/internat ... clare.html for more (like the proper xhtml declaration, which remains poorly supported)
Post Reply