Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: A UTF8 round trip with MySQL

by Anonymous Monk
on Mar 30, 2009 at 18:49 UTC ( [id://754217]=note: print w/replies, xml ) Need Help??


in reply to Re: A UTF8 round trip with MySQL
in thread A UTF8 round trip with MySQL

I use perl -C (or sets the shell environment variabel PERL_UNICODE=""), and then you do not need any utf8 specific parameter in the code unless the column (or table) names are non-ascii. If they are, mysql_enable_utf8 => 1 have to be set.
$dbh = DBI->connect($dsn, $username, $password, {mysql_enable_utf8 => +1}) || die "Could not connect to $database: $DBI::errstr"; $sth->execute || die "Could not execute statement: ".$sth->errstr."\n" +; $sth = $dbh->prepare("select foo from bar where id = '3064'") || die " +Could not prepare statement: ".$dbh->errstr."\n"; my $string = $sth->fetchrow_array; print $string . "\n";
Will print utf8 to STDOUT.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://754217]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-19 20:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found