Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #3972
| Newsgroups | comp.lang.php |
|---|---|
| From | TnT <noemail@yahoo.com> |
| Subject | PDO breaking UTF8 characters |
| Message-ID | <slrnjdb15i.3a2.noemail@news.easynews.com> (permalink) |
| Organization | EasyNews, UseNet made Easy! |
| Date | 2011-11-30 01:19 +0000 |
I have been trying to track down an issue with certain Greek characters
getting jumbled in my web app, and I am stumped. I have the issue isolated
to the characters getting messed up between the MySQL database and PDO. If
I select from the database via the MySQL command line it comes out right. If
I use PHP/PDO it gets jumbled. Any ideas? Here is an example of the issue,
using the Ω character:
% php utf8.php
This is a test Ω of the emergency broadcast system
% utf8.sh
entry
This is a test Ω of the emergency broadcast system
-----------------------------------------------------------
% cat utf8.php
<?php
// connect
$db=new PDO("mysql:host=localhost;dbname=testdb", "root", "password");
// force UTF8
$db->query('SET NAMES utf8');
// select single row
$result=$db->query("select entry from employee where id=3640");
$row=$result->fetch(PDO::FETCH_ASSOC);
// print row
print $row['entry'] . "\n";
?>
-----------------------------------------------------------
% cat utf8.sh
echo "select entry from employee where id=3640" | \
mysql -h localhost -u root --pass='password' testdb
Thanks!
Back to comp.lang.php | Previous | Next — Next in thread | Find similar | Unroll thread
PDO breaking UTF8 characters TnT <noemail@yahoo.com> - 2011-11-30 01:19 +0000 Re: PDO breaking UTF8 characters "Peter H. Coffin" <hellsop@ninehells.com> - 2011-11-29 20:23 -0600 Re: PDO breaking UTF8 characters Marco Muracchioli <"marco.muracchioli togli_qui[at] gmail.togli_qui.com"> - 2011-12-01 10:33 +0100
csiph-web