[实践Ok]Mysql连接升级为Mysqli函数对应关系以解决The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in 报错

jackxiang 2016-2-12 20:10 | |
解决Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future:
mysqli 更严谨 安全 高效

php 5个版本,5.2、5.3、5.4、5.5,怕跟不上时代,新的服务器直接上5.5,但是程序出现如下错误:Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in,看意思就很明了,说mysql_connect这个模块将在未来弃用,请你使用mysqli或者PDO来替代。

解决方法1:
禁止php报错
display_errors = On
改为
display_errors = Off

鉴于这个服务器都是给用户用的,有时候他们需要报错(…都是给朋友用的,^_^),不能这做,让他们改程序吧,看方案2.

解决方法2:
<?php
error_reporting(E_ALL ^ E_DEPRECATED);

以上来自:http://www.cnblogs.com/bjxing/p/3555929.html
————————————————————————————————————————————————————————————



解决The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in 报错
很明显的提示 mysql扩展模块就要被放弃使用了,所以请使用mysqli代替

这个说明你的php版本过高造成的。

解决方法:
把mysql的相关模块全都改为mysqli就行了。
比如:
1、mysql_connect 改为mysqli_connect

2、mysql_query 改为mysqli_query

3、mysql_close 改为 mysqli_close

4、mysql_select_db 改为 mysqli_select_db

5、mysql_error 改为 mysqli_error

等等!
来自:http://www.inbeijing.org/archives/1017


———————————————————————————————————
mysql_select_db  ==> mysqli_select_db:


来自:http://www.runoob.com/php/func-mysqli-select-db.html


用mysqli的函数连接mysql出现warning: mysqli::real_connect(): (hy000/1040): too many connections in :
https://jackxiang.com/post/8500/

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/8498/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2016-2-13 02:00
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]