winson 发表于 2018-12-19 12:34:37

2015

  系统:windows 10 10036

  环境:Apache2.4 + php 5.6.5 + mysql 5.5
  学习内容:PHP连接数据库 分别有mysqli mysql
  出现的问题 :
  Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in D:\wamp\www\0316\phpdev_connect.php on line8
解决办法:
  一、
  禁止php报错:
  display_errors = on
  改为
  display_error = off
  二、
  在代码里添加:
  error_reporting(E_ALL ^E_DEPRECATED);
  

  三、
  hod to solve the warnings?
  currently mostly many mysql connection in php use this construct
  mysql:
    $link = mysql_connect('localhost','user','password');
    mysql_select_db('dbname',$link);  mysqli:
  $link = mysqli_connect('localhost','user','password','dbname');
  To run databae queries is also simple and nearly identical with the old way:
//old
      mysql_query('create temporary table `table`',$link);
      //new
      msyqli_query($link,'create temporary table `table`');  

  filthy and fastest solutin:
页: [1]
查看完整版本: 2015