类别:PHP问题 / 日期:2019-11-26 / 浏览:177 / 评论:0

php7不能用mysql

很多人从php5+升级到php7后,顺序没法一般运转,尤其是mysql数据库没法衔接,下面来看下解决方法。

升级完php7以后发明有些已做好的放在当地的项目竟然不能一般使用了,这是由于mysql_类的函数已被php7烧毁,实在早在php5的时刻官方已明白示意过行将烧毁这类函数,以下是php5和php7关联数据库后查询数据的对照:

php5:
<?php
    header("content-type:text/html;charset=utf-8");
    error_reporting(E_ALL ^ E_DEPRECATED);
    $link = mysql_connect("127.0.0.1","root","123456");
    mysql_select_db("shunyi",$link);
    mysql_query("set names utf8");
    $point = "select * from sy_location";
    $rest = mysql_query($point);
    $arr = array();
    while($re = mysql_fetch_assoc($rest)){
        array_push($arr, $re);
    }
    echo json_encode($arr);
?>
php7:
<?php
    header("content-type:text/html;charset=utf-8");
    error_reporting(E_ALL ^ E_DEPRECATED);
    $link = mysqli_connect("127.0.0.1","root","123456","shunyi");
    $point = "select * from sy_location";
    $rest = mysqli_query($link,$point);
    $arr = array();
    while($re = mysqli_fetch_assoc($rest)){
        array_push($arr, $re);
    }
    echo json_encode($arr);
?>

更多PHP相干学问,请接见ki4网!

以上就是php7不能用mysql的细致内容,更多请关注ki4网别的相干文章!

打赏

感谢您的赞助~

打开支付宝扫一扫,即可进行扫码打赏哦~

版权声明 : 本文未使用任何知识共享协议授权,您可以任何形式自由转载或使用。

 可能感兴趣的文章