php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32927 inserting UTF-8 string into mysql
Submitted: 2005-05-03 15:39 UTC Modified: 2005-05-13 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: david dot kalosi at spordat dot sk Assigned:
Status: No Feedback Package: *Languages/Translation
PHP Version: 5CVS-2005-05-03 (dev) OS: Windows XP SP1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david dot kalosi at spordat dot sk
New email:
PHP Version: OS:

 

 [2005-05-03 15:39 UTC] david dot kalosi at spordat dot sk
Description:
------------
I have a Mysql database with UTF-8 encoding and i am posting data from web also in UTF-8 encoding. 
The slovak character "č" is messed up - the results from the database are differ from the input. All other special characters are OK.

Reproduce code:
---------------
mysql> create table t (x varchar(64)) character set utf8;
Query OK, 0 rows affected (0.21 sec)

mysql>

<script language="php">

header("Content-Type: text/html;charset=UTF-8");

$l_conn = mysql_connect("localhost", "formawww", "formawww");
mysql_select_db("forma", $l_conn);


echo "<form name=\"test\" method=\"POST\" action=\"test.php\">";
echo "<input type=\"text\" name=\"str\">";
echo "<input type=\"hidden\" name=\"insert\" value=\"1\">";
echo "<input type=\"submit\"></form>";


if (isset($_REQUEST["insert"]))
{
    $l_insert = mysql_query ("insert into t values ('" . $_REQUEST["str"]."')");
}



$l_select = mysql_query("select * from t");

echo "------------------<br>";
while ($l_row = mysql_fetch_assoc($l_select))
{
  echo $l_row["x"] . "<br>\n";
}


</script>

Expected result:
----------------
enter the following values into the form 

&#318;?&#269;&#357;????????

and the following output is produces

&#318;?&#319;&#357;????????

the third character is corrupted.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-03 23:14 UTC] iliaa@php.net
Pass the input through mysql_real_escape_string().
 [2005-05-04 00:03 UTC] david dot kalosi at spordat dot sk
does not help either - the same character is corrupt again.
 [2005-05-05 10:25 UTC] georg@php.net
Which MySQL Version do you use (client and server) ?
Which default charset does your client library use?
 [2005-05-13 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 14:01:28 2024 UTC