BiL
BiL

Reputation: 107

How to retrieve currency symbol from database using php?

I have a customer database and i m retrieving customer's company name from one of the tables (cache_cust).I am saving 'company_name' in this format e.g Mr €2 , Mr €1 , £ land etc. These currency symbols are saving correctly in the database.BUT when i try to retrieve the 'company_name' values they show me characters like this:

For example : for "  Mr €2 " ,it shows " Mr €2   "  .

How can i display my data on the php page as it is saved in the database?How can i avoid these kind of symbols appearing on my web page?PLEASE note that these values are coming from the database.I have tried htmlspecialcharacters and htmlentities but they didn't work.Please help.Thanks

AN UPDATE: When i try to post the 'company_name' text box value to next page and try to retrieve it using print($_POST['company_name]); ,it Still DOESN'T display the symbols and doesn't include special characters.

Upvotes: 0

Views: 1558

Answers (2)

djjjuk
djjjuk

Reputation: 358

how is your page rendered - in PHP? if so, try putting the content type as UTF-8:

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

Upvotes: 1

cloakedninjas
cloakedninjas

Reputation: 4176

What is the character set / collation for the company_name field?

It sounds like you have the default character set latin1. You will need to set it to UTF-8 utf8_unicode_ci if this is the case.

Also be aware if the column isn't UTF8 - any special characters you have already saved into it will need to re-saving since they will have been converted from their multi-byte form into single-byte representation. You can use this chart to perform string replacements if you are in that situation.

Upvotes: 0

Related Questions