php解决数据库乱码问题
来源:程序员人生 发布时间:2013-11-06 23:02:23 阅读次数:2211次
数据库是用UTF-8的话,你那个文本是使用什么编码呀?
用mb_convert_encoding或iconv来转换一下编码,两个编码要一致才不会出现乱码的。还有就是数据库连接方面,如果你有加了set names应该是全部的连接都要那样去加,要不然,会显示乱码的。下在的例题如果不进行编码转换就会有问题.
- $fileName = "qtgz/qtgongzi.txt";
- $fContent = file($fileName);
-
- foreach($fContent as $a_content) {
- list($QT_sfz,$QT_xm,$QT_bz,$QT_je) = explode( ",",$a_content);
- if($QT_sfz!= "" and $QT_xm !="" and $QT_bz !="" and $QT_je !=""){
- echo $QT_xm;
-
- $QT_sj = date("Ym");
- $query = "insert into qita(QT_sfz,QT_xm,QT_bz ,QT_je,QT_beizhu,QT_sj) values('$QT_sfz','$QT_xm','$QT_bz','$QT_je','$QT_beizhu','$QT_sj')";
-
- $rst = $aa->excu($query);
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠