解决Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 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来替代。

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语法连接mysql如下

<?php
$link = mysql_connect('localhost''user''password');
mysql_select_db('dbname'$link);
 
改成mysqi
<?php
$link = mysqli_connect('localhost''user''password''dbname');

常用mysql建表SQL如下

<?php
//  老的
mysql_query('CREATE TEMPORARY TABLE `table`'$link);
// 新的
mysqli_query($link'CREATE TEMPORARY TABLE `table`');

解决方法三:

在php程序代码里面设置报警级别

<?php
error_reporting(E_ALL ^ E_DEPRECATED);

Deprecated的问题就这样解决掉了,不过还是建议大家尽快取消mysql的用法,全部都走向mysqli或者mysqlnd等等。mysql确实是太不安全而且太老旧了。


 

CI中出现提示:

mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

解决方法:

将数据库配置文件中DB驱动修改为即可(mysql是被淘汰的函数,用mysqli即可):

$db['default']['dbdriver'] = 'mysqli';
如何联系我:【万里虎】www.bravetiger.cn 【QQ】3396726884 (咨询问题100元起,帮助解决问题500元起) 【博客】http://www.cnblogs.com/kenshinobiy/
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
6月前
|
关系型数据库 MySQL 数据库
表格存储有类似mysql的use的切换方式吗
表格存储有类似mysql的use的切换方式吗?
39 3
|
4月前
|
关系型数据库 MySQL
【XAMPP启动mysql报错】Port 3306 in use by ““C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld“……
【XAMPP启动mysql报错】Port 3306 in use by ““C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld“……
|
8月前
|
SQL 关系型数据库 MySQL
check the manual that corresponds to your MySQL server version for the right syntax to use near lin
注意这种一般情况下是语法问题,说明mysql的各种语句还是不够熟练, (1)看表名是不是使用了Mysql的关键字,如果是,请立马改掉; (2)语句给出哪里错误,如我的题目中给出“near”,说明在那附近有问题。 (3)检查mybatis中mapper里sql语句占位符是否写对,我的问题是将#{name}写成了#(name),尴尬。
133 0
|
11月前
|
Java 关系型数据库 MySQL
Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is `com.mysql.cj.jdb
Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is `com.mysql.cj.jdb
122 0
|
关系型数据库 MySQL 数据库
快速解决:Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is `com.mysql.c
我们当前使用的数据库版本在6.0以上,原来的驱动(com.mysql.jdbc.Driver)已经被废弃了,要进行更换驱动就好了
29523 1
快速解决:Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is `com.mysql.c
|
关系型数据库 MySQL
Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is `com.mysql.cj.jdb
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.异常错误问题及解决方法。
|
SQL 关系型数据库 MySQL
check the manual that corresponds to your MySQL server version for the right syntax to use near
check the manual that corresponds to your MySQL server version for the right syntax to use near
717 0
check the manual that corresponds to your MySQL server version for the right syntax to use near
|
关系型数据库 MySQL
check the manual that corresponds to your MySQL server version for the right syntax to use near '...
背景交代 折扣价格设置的是负数,框架用的TP5。 活动规则:当活动开始时候销售价格加上折扣价格(相当于减折扣价格)就是活动价格,当活动结束时候,减去折扣价格(负负得正)就恢复原价。
6906 0
|
关系型数据库 MySQL 数据库连接