posting £ symbol as £

How do I post a £ symbol into a mysql table field as the html equivalent?

i.e. £

as currently the value posted is £25K

Why does it add the "Â"?
petewinterAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Gurvinder Pal SinghConnect With a Mentor Commented:
how does it matter what you enter in database at first place, since it will show £ symbol again when you will fetch it back from database?



0
 
svgmucCommented:
Enable latin1 and you should be able to use the UK pound sign.
0
 
Gurvinder Pal SinghCommented:
use £ for pound symbol

see this table
http://www.ascii.cl/htmlcodes.htm
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
leakim971PluritechnicianCommented:
Before posting, (use the onsubmit attribute of your form for example) you may use the function HTMLentities(texte) from here : http://www.editeurjavascript.com/forum/topic,2,39285,0.html
0
 
petewinterAuthor Commented:
So when I post the value do I need to wrap this code with something?

$_POST["salary"]
0
 
Gurvinder Pal SinghCommented:
You don't have to decode it back it, if you use the html code £
 
0
 
petewinterAuthor Commented:
How can I do that?

In the form text field users will just enter "£"? How can I convert it to £ ?
0
 
Gurvinder Pal SinghCommented:
0
 
petewinterAuthor Commented:
Does that make sense?

Users are entering the £ symbol in a text field and I need it to be entered into my mysql database as £
0
 
leakim971PluritechnicianCommented:
>Users are entering the £ symbol in a text field and I need it to be entered into my mysql database as £

Use :

myform.onsubmit = function() {
      //var salary = document.getElementById("salary");
      var salary = document.getElementsByName("salary")[0];
      salary.value = encodeURIComponent(HTMLentities(salary.value));
}

Open in new window

0
 
petewinterAuthor Commented:
The problem is it gets entered as "£" for some reason instead of "£" Any idea's why it does this?
0
 
leakim971Connect With a Mentor PluritechnicianCommented:
£ -> utf8

Use the same format everywhere : in your page, your database, server language
Should be UTF-8 to avoid this type of problem
0
 
petewinterAuthor Commented:
I just change the field collation to utf8_unicode_ci , but still the same problem?
0
 
petewinterAuthor Commented:
Thanks you have made me realise where I am going wrong.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.