• PHP 学习1.1


    1 链接mysql 数据简单测试

      <html>
    <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>
    <?php
      $mysqli = new mysqli();
      $mysqli->connect("localhost","root","sulin","test");
      if($mysqli->errno == 0)
            {
               $sql = "SELECT * FROM table_1";
               $result = $mysqli->query($sql);
               echo "<br/>Result row nums:".$result->num_rows."<br/>";
               while(list($id,$name,$birthday,$remark) = $result->fetch_row())
               {
                   echo "$id : $name : $birthday : $remark"."<br/>";
               }
            }
            else
            {
                echo "The Connection is Error!";
                exit();
            }

        $mysqli->close();
    ?>
    </body>
    </html>

    mysql 设置:

    ALTER DATABASE  test  DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
    ALTER TABLE  table_1 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

    SET character_set_client='utf8';
    SET character_set_connection='utf8';
    SET character_set_results='utf8';

    php 和mysql 的字符设置必须一样,否则就是乱码

  • 相关阅读:
    sublimeformaya
    sitecustomize.py 用法
    计蒜客之矩阵翻转
    计蒜客之判断质数
    计蒜客之斐波那契数列
    LTE 测试文档(翻译)
    Manual——Test (翻译1)
    LTE Manual ——Logging(翻译)
    嵌入式linux的学习之路[转]
    C语言预处理程序[转]
  • 原文地址:https://www.cnblogs.com/linsu/p/3469553.html
Copyright © 2020-2023  润新知