|
Posted by ben on 11/02/46 11:30
Hi all,
I have a simple PHP page that takes values from a form and puts them in a
database (MySQL).
The code is in a file test.php, which I have typed in at the bottom of
this post (please excuse any typos). This page is not a production page -
I created it just to try and solve the £ sign problem I am having.
When I put the pound sign (£) into the input box and submit the form,
what gets inserted into mysql is an A with a ^ on top, followed by the
pound sign. I notice that the request URI shows the £ sign as %C2%A3. If
I run the query manually in php (i.e. mysql_query("INSERT INTO test
VALUES('£')") ) then it is fine. (The problem occurs with both GET and
POST)
I have read up a bit about it and I believe that the problem is that one
part of the system uses UTF-8 while the other part uses ISO-8859-1. The
database is ISO-8859-1 (latin1).
Using phpmyadmin, I can put a £ sign into the database with no problem,
so I know that there must be a solution to this issue within PHP, but I
have no idea what it is!!!!
Any clues appreciated :)
Cheers,
Ben
--
test.php:
<?php
mysql_connect('localhost', 'root', '');
mysql_select_db("test");
mysql_query("INSERT INTO test VALUES('".$_REQUEST['testpound']."')");
?>
<HTML>
<BODY>
<form action="test.php">
<input name="testpound">
<input type="submit">
</form>
</body>
</html>
[Back to original message]
|