£ signs

Soldato
Joined
19 Jul 2006
Posts
2,967
Location
Leicester
On my PHP page, whenever I enter a £ sign in my code just to display it, it comes up like this:
pound.jpg


When using the system and I enter a £ sign in the "Price" field, it saves it to my database like this:
pound1.jpg


Could you help me so I get the £ sign on both Webpage and database.

Thanks
 
Thanks fini, it's fixed the display issue on the Webpage by using £ but in the database it's still showing that a before it, but $ sign works fine.

Before I put a fixed value in the text box of £, is there any way to sort it so the user can type the £ sign?

Thank you

Edit - Even with the £ as a fixed value in the text area, it's still showing that a in the database.
 
Last edited:
Do you actually need to store the pound sign in the database? It doesn't sound like a great idea to me.

You may have to change the encoding/collation to support pound signs, not sure which one you'll need though. Try utf8.
 
I'd like to display the £ sign in the database so when I call the information on another page, it'll show the price with the pound sign.
An alternative I suppose is to just store the value e.g. 5.99 then concatenate that on the end of a £ on my output page.

The collation is on utf8_generel_ci
 
I'd like to display the £ sign in the database so when I call the information on another page, it'll show the price with the pound sign.
An alternative I suppose is to just store the value e.g. 5.99 then concatenate that on the end of a £ on my output page.

I would recommend doing that, that way you don't have to remove the pound sign if you wish to perform any operations on the values. I expect it is bad practice to store it in the database, but I'm not certain ;)
 
Yup, bad practice to include the currency symbol with the cost. It means it's harder to do calculations and it's just generally not a good idea. Just include the £ symbol on output and if your site works across multiple currencies then link each cost to an ID with a list of IDs/symbols in another database.
 
Or just do what electronics companies do and use a $1=£1 conversion rate and then it doesn't matter which sign you show :D
 
utf-8 encoding would fix that particular problem. you can set it using a content-type header. There are also ways of fixing this in ASP code but I'm not 100% sure about PHP. I know in ASP you can programmatically set the content type and charset to UTF-8 and also use the 'Codepage' setting to ensure weird characters like this display correctly.
 
I agree that UTF8 would fix that problem, but I see it as very bad practice to store prices as strings in a database, let alone with the currency sign attached. Prices are numbers, and should be stored as such whenever possible.

And yes, before someone jumps down my throat, I know they'll probably end up as strings in PHP/ASP/whatever, but that isn't the point.
 
Back
Top Bottom