FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PDO breaking UTF8 characters
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
PDO breaking UTF8 characters [message #176175] Wed, 30 November 2011 01:19 Go to previous message
TnT is currently offline  TnT
Messages: 1
Registered: November 2011
Karma:
Junior Member
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!
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: PHP-HTML-Javascript opportunities with Yahoo R&D!!!
Next Topic: eAccelerator Compilation problem on Mac OS X Snow Leopard Server
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 14:35:22 GMT 2024

Total time taken to generate the page: 0.04894 seconds