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
Re: PDO breaking UTF8 characters [message #176196 is a reply to message #176175] Thu, 01 December 2011 09:33 Go to previous message
Marco Muracchioli is currently offline  Marco Muracchioli
Messages: 1
Registered: December 2011
Karma:
Junior Member
Hi,

try with a:

ini_set('default_charset', 'UTF-8');

before doing anything else.

Regards,
Marco


On 30/11/2011 02:19, TnT wrote:
> 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: Sun Nov 10 14:43:36 GMT 2024

Total time taken to generate the page: 0.05120 seconds