php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74212 Prepare destroys some UTF-8 characters on Insert
Submitted: 2017-03-06 16:25 UTC Modified: 2017-03-19 04:22 UTC
From: michael dot kaiser at winzeldorf dot de Assigned:
Status: No Feedback Package: PDO MySQL
PHP Version: 5.6.30 OS: Linux
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: michael dot kaiser at winzeldorf dot de
New email:
PHP Version: OS:

 

 [2017-03-06 16:25 UTC] michael dot kaiser at winzeldorf dot de
Description:
------------
It is not possible to insert turkish UTF8 characters (like in the name Elit İşcan) into a MySQL database via PDO.
I tried MyISAM tables and InnoDB tables.
I tried utf8, utf16, utf32, utfmb4 and ISO 8859-9 Turkish (latin 5)

Test script:
---------------
// Does not work:
$query = "INSERT INTO utf8test (Name) VALUES ("Elit İşcan")";
$pdo = $db->prepare($query);
$pdo->execute();
// Results in entry "Elit ??can".



Expected result:
----------------
Database entry should read "Elit İşcan"

Actual result:
--------------
Database entry is "Elit ??can"

Old MySQL command works:
$query = "INSERT INTO utf8test (Name) VALUES ("Elit İşcan")";
mysql_query(query);
Results in entry "Elit İşcan".

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-03-06 17:15 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2017-03-06 17:15 UTC] requinix@php.net
This is unlikely to be a bug with PDO.

Check that you are using UTF-8 (or whichever encoding) for all aspects of the database - do "SHOW VARIABLES LIKE '%conn%'" to see. Then make sure whatever you're using to read the database is connecting properly as well, and that the output is in UTF-8 too. And obviously, the file must be in UTF-8 encoding as well since you're hardcoding the string in it.

Also check that you get the same behavior with mysql/mysqli using the exact same connection parameters, and with PDO's regular (non-prepared) queries.
 [2017-03-19 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 09:01:29 2024 UTC