Solved

posting £ symbol as £

Posted on 2011-03-15
14
532 Views
Last Modified: 2012-05-11
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 "Â"?
0
Comment
Question by:petewinter
  • 6
  • 4
  • 3
  • +1
14 Comments
 
LVL 14

Expert Comment

by:svgmuc
Comment Utility
Enable latin1 and you should be able to use the UK pound sign.
0
 
LVL 40

Expert Comment

by:gurvinder372
Comment Utility
use £ for pound symbol

see this table
http://www.ascii.cl/htmlcodes.htm
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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
 

Author Comment

by:petewinter
Comment Utility
So when I post the value do I need to wrap this code with something?

$_POST["salary"]
0
 
LVL 40

Expert Comment

by:gurvinder372
Comment Utility
You don't have to decode it back it, if you use the html code £
 
0
 

Author Comment

by:petewinter
Comment Utility
How can I do that?

In the form text field users will just enter "£"? How can I convert it to £ ?
0
 
LVL 40

Expert Comment

by:gurvinder372
Comment Utility
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:petewinter
Comment Utility
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
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 250 total points
Comment Utility
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
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
>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
 

Author Comment

by:petewinter
Comment Utility
The problem is it gets entered as "£" for some reason instead of "£" Any idea's why it does this?
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 250 total points
Comment Utility
£ -> utf8

Use the same format everywhere : in your page, your database, server language
Should be UTF-8 to avoid this type of problem
0
 

Author Comment

by:petewinter
Comment Utility
I just change the field collation to utf8_unicode_ci , but still the same problem?
0
 

Author Closing Comment

by:petewinter
Comment Utility
Thanks you have made me realise where I am going wrong.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now