mysql dbi utf8乱码问题

来源:互联网 发布:js prompt怎么取消判断 编辑:程序博客网 时间:2024/06/08 14:05
<pre name="code" class="python">jrhdpt02:/root/sbin# cat t1.pl #!/usr/bin/perl  use DBI;  $user="root";  $passwd="xxxxx";  $dbh="";  $dbh = DBI->connect("dbi:mysql:database=zjzc;host=127.0.0.1;port=3306",$user,$passwd) or die "can't connect to  database ". DBI-errstr;  #$dbh->do("SET NAMES utf8"); $sth=$dbh->prepare("select sn,duration,name,maxUnit,addUnit,productType from  zjzc.Product  where sn in (263,121,122);");  $sth->execute;  while (@recs=$sth->fetchrow_array) {  foreach (@recs)         {print "$_"}                       print "\n";                                     }                         $dbh->disconnect; jrhdpt02:/root/sbin# perl t1.pl 12123??-??30?25000001112222????-????5170000100003263180????-????2000000100003jrhdpt02:/root/sbin# cat t1.pl #!/usr/bin/perl  use DBI;  $user="root";  $passwd="R00t,uHagt.0511";  $dbh="";  $dbh = DBI->connect("dbi:mysql:database=zjzc;host=127.0.0.1;port=3306",$user,$passwd) or die "can't connect to  database ". DBI-errstr;  $dbh->do("SET NAMES utf8"); $sth=$dbh->prepare("select sn,duration,name,maxUnit,addUnit,productType from  zjzc.Product  where sn in (263,121,122);");  $sth->execute;  while (@recs=$sth->fetchrow_array) {  foreach (@recs)         {print "$_"}                       print "\n";                                     }                         $dbh->disconnect; jrhdpt02:/root/sbin# perl t1.pl 12123中均-至信30号25000001112222中均尊享-贰拾壹号5170000100003263180中均尊享-玖拾伍号2000000100003


                                             
0 0
原创粉丝点击