这篇文章主要介绍了PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法,是在进行PHP数据库程序开发中常会遇到的错误,需要的朋友可以参考下
 

本文实例讲述了PHP提示 Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法,在PHP程序开发中常会遇到这类问题。分享给大家供大家参考,具体的解决方法如下:

将下面代码改为mysqli或PDO即可。

1
2
3
4
5
function connectit () {
global $CFG;
mysql_connect($CFG['db_host'], $CFG['db_user'], $CFG['db_pass']) or die(mysql_error());
mysql_select_db($CFG['db_name']);
}

PDO:

1
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);

MYSQLI:

1
2
3
4
5
6
7
8
9
10
$link = mysqli_connect(
 'localhost', /* The host to connect to 连接MySQL地址 */  
 'user',   /* The user to connect as 连接MySQL用户名 */  
 'password', /* The password to use 连接MySQL密码 */  
 'world');  /* The default database to query 连接数据库名称*/  
 
if (!$link) {
  printf("Can't connect to MySQL Server. Errorcode: %s ", mysqli_connect_error());
  exit;
}

希望本文所述对大家的PHP程序设计有所帮助。

PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法的更多相关文章

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

    你有碰上过这样的提示吗? Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in t ...

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

    转载 php 5个版本,5.2.5.3.5.4.5.5,怕跟不上时代,新的服务器直接上5.5,但是程序出现如下错误:Deprecated: mysql_connect(): The mysql ext ...

  3. 解决Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future:

    php 5个版本,5.2.5.3.5.4.5.5,怕跟不上时代,新的服务器直接上5.5,但是程序出现如下错误:Deprecated: mysql_connect(): The mysql extens ...

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

    php 5个版本,5.2.5.3.5.4.5.5,怕跟不上时代,新的服务器直接上5.5,但是程序出现如下错误:Deprecated: mysql_connect(): The mysql extens ...

  5. 错误Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future:

    今天写PHP代码,遇到了这个非常不友好的报错(Deprecated: mysql_connect(): The mysql extension is deprecated and will be re ...

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

    因为最近更新的PHP版本,写sql语句,忽然发现不能用了,上网查了一些原因,找到几个方法如下: 1.禁止php报错 display_errors = on 改成 display_errors = of ...

  7. MYSQL版本问题:解决Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future.

  8. [mysql] mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in

    From: http://www.ttlsa.com/php/deprecated-mysql-connect/ php 5个版本,5.2.5.3.5.4.5.5,怕跟不上时代,新的服务器直接上5.5 ...

  9. 解决MYSQL弃用模块错误Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future

    今天使用了mysql 5.5版本,就出现了错误.错误提示如下: Deprecated: mysql_connect(): The mysql extension is deprecated and w ...

随机推荐

  1. typedef block

    给同一种类型的block定义一个别名 typedef int (^MyBlock) (int , int); int main(int argc, const char * argv[]) { @au ...

  2. Excel数据通过plsql导入到Oracle

    Excel数据通过plsql导入到Oracle 1 准备Excel导入数据 2 把Excel文件另存为(文本文件(制表符分隔)(*.txt)) 或者将Excel文件另存为(Unicode文本) 之后唯 ...

  3. 新浪SAE数据库信息wordpress设置(用户&密码&主地址)

    新浪SAE数据库信息wordpress设置(用户&密码&主地址) 此账号仅能在SAE平台上使用,不能从外部连接我们建议开发者使用SaeMysql操作数据库如果您想自己实现数据库相关操作 ...

  4. ActiveMQ讯息传送机制以及ACK机制详解

    [http://www.ylzx8.cn/ruanjiangongcheng/software-architecture-design/11922.html] AcitveMQ:消息存储和分发组件,涉 ...

  5. iepngfix.htc让PNG-24在IE6中透明的方法(转)

    add:360用的一个方法: <!--[if IE 6]> <script src="http://se.360.cn/js/DD_belatedPNG.js"& ...

  6. Mac OS X取消Apache(httpd)开机启动

    安装MAMP后,启动服务时提示Apache启动失败,80端口被占用.查看进程发现存在几个httpd. OS X自带Apache,可是默认是没有启动的.我也没有开启Web共享,怎么就开机启动了呢? 不知 ...

  7. Rstudio安装

    1.https://www.r-project.org/下载R语言(注意32位还是46位系统). 2.安装R,尽量默认安装路径,安装路径不要有中文. 3.https://www.rstudio.com ...

  8. 也来说说C#异步委托(转)

    原文地址: http://www.cnblogs.com/lxblog/archive/2012/12/11/2813893.html 前些日子,看到园子里面有人用老王喝茶的例子讲解了一下同步和异步, ...

  9. 语义化的HTML

    div:division(分开, 分割, 区分,分配, 分界线),标签可以把文档分割为独立的.不同的部分.作为块级元素的代表,因为没有固定的格式表现,目前滥用情况最严重.ul:Unordered Li ...

  10. Codeforces Round #342 (Div. 2) D. Finals in arithmetic 贪心

    D. Finals in arithmetic 题目连接: http://www.codeforces.com/contest/625/problem/D Description Vitya is s ...