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

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

    <?php
        error_reportion(E_ALL ^E_DEPRECATED);


你可能感兴趣的:(PHP,error,deprecated)