且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

2015-3-18 学习出错问题解决--PHP Deprecated问题

更新时间:2021-11-11 01:54:07

系统: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:

    

1
2
    $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:

      

1
2
3
4
  //old 
        mysql_query('create temporary table `table`',$link);
        //new
        msyqli_query($link,'create temporary table `table`');


filthy and fastest solutin:

1
2
    <?php
        error_reportion(E_ALL ^E_DEPRECATED);

本文转自孤舟夜航之家博客51CTO博客,原文链接http://blog.51cto.com/cysky/1622081如需转载请自行联系原作者

cysky