爱问知识人 爱问教育 医院库

php 中文字符入库或显示乱码问题的解决方法

首页

php 中文字符入库或显示乱码问题的解决方法


        

提交回答
好评回答
  • 2023-03-08 01:30:00
      大家以后在编写过程中, 一定要记得定义字符类型。
    mysql_query("set names 'gbk'")
    解决的方法就这么简单。
    今天做了一个数据库查询,放出代码。
    代码如下:
    <php
    /*
    filename:query。
      php
    do:get and show the data
    author:www。5dkx。com
    */
    include_once("conn。php");
    include_once("include。
      php");
    mysql_query("set names 'gbk'")or die("设置字符库失败\n");
    mysql_select_db($db)or die("连接数据库失败!\n");
    $exec = "select * from $table";
    //echo $exec;
    $result = mysql_query($exec,$conn)or die("查询数据库失败\n");
    echo "<table border=2>";
    for($cout=0;$cout<mysql_numrows($result);$cout++)
    {
    $city = mysql_result($result,$cout,city);
    $name = mysql_result($result,$cout,name);
    $phone = mysql_result($result,$cout,phone);
    echo "<tr>";
    echo "city: $city";
    echo "name: $name";
    echo "phone: $phone";
    echo "</tr>";
    }
    echo "</table>";
    ?>

      

    王***

    2023-03-08 01:30:00

类似问题

换一换

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):