这篇文章主要介绍了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. A Dream

    A Dream 2013年10月20日,成都,天气阴,铜牌16.离2012年10月14日长春现场赛刚好隔了一年,刚看了下去年写的总结http://blog.csdn.net/cc_again/arti ...

  2. hdoj 5335 Walk Out

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5335 #include<stdio.h> #include<cstring> ...

  3. [XAF]如何在非按钮事件中打开视图

    private static void OpenDetailView(XafApplication app) { IObjectSpace os = app.CreateObjectSpace(); ...

  4. nhibernate操作sql2008数据库(添加数据失败)

    今天遇到一错误困了我一天,如此痛恨,遂记录于此: nhibernate框架+MVC模式搭的项目,添加数据时报错: "could not insert: [KXRMallManage.Mode ...

  5. 修改SVN账户密码的方法

        Case1:     在Eclipse 使用SVN 的过程中大多数人往往习惯把访问SVN 的用户名密码自动保存起来以便下次自动使用,不要再次手工输入,但是有些时候需要变更密码或者用户名,这时候 ...

  6. easymock入门贴

    from:http://macrochen.iteye.com/blog/298032 关于EasyMock常见的几个问题, 这里(http://ozgwei.blogspot.com/2007/06 ...

  7. 使用Python脚本进行域名解析

    因为在研究爬虫,所以也了解了下域名解析.要提高爬虫的效率,就需要提高域名解析的效率.我将爬虫记录下的域名作为待解析的域名来测试各域名解析方法的效率.我尝试以下四种方法:1. 单线程依次解析各域名,2. ...

  8. 应该把script标签放在哪里

    应该把script标签放在哪里 目录: 1script标签放在底部的好处 2应该放在底部的哪里   概述: 如果在页面中写JS的话,那必然会用到script标签,理论上script标签放在哪里都是可以 ...

  9. [Javascript] Promise-based functions should not throw exceptions

    Source You can also start a chain of then() method calls via Promise.resolve() and execute the synch ...

  10. python 中sys.stdout.write 和 print >> sys.stdout的区别(转)

    下面应该可以解你的惑了: print >> sys.stdout的形式就是print的一种默认输出格式,等于print "%VALUE%" 看下面的代码的英文注释,是p ...