I have a website where users enter a salary into a field and then it gets entered into the MySQL database. If I enter £75k it should get entered into the database as £75k. However, it’s getting entered as £75k.
I have really run out of ideas what may be causing this. It must be something on the frontend, as i’m using the same code on other websites and all work fine.
Thanks, that seems to have fixed it. However, I just noticed on the other sites (where it is working) that the £ is also stored as £ in the database - yet on the frontend when the information is displayed, only the £ symbol shows (which is correct). I am not using any utf-8 decoding when getting the results from the database either. No idea whats going on here…
Most probably the “incident” is a result of different server settings on the web sites.
Which has helped with the previous systems for example is setting the web server charset to UTF-8 or/and the database also doing the same automatically.
If your code is to be deployed on multiple systems that you do not have absolute control on the server settings, I would recommend setting the code up with both sending a charset header and always setting the database connection to the correct charset.
I know how to set the database connection with the correct charset, but how do you send a charset header? Is that in the header for the page? I’m not sure what header is being referred to. Thanks!