PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法
更新时间:2014年08月28日 12:06:57 投稿:shichen2014
这篇文章主要介绍了PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法,是在进行PHP数据库程序开发中常会遇到的错误,需要的朋友可以参考下
本文实例讲述了PHP提示 Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法,在PHP程序开发中常会遇到这类问题。分享给大家供大家参考,具体的解决方法如下:
将下面代码改为mysqli或PDO即可。
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:
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
MYSQLI:
$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程序设计有所帮助。
相关文章
php5.3提示Function ereg() is deprecated Error问题解决方法
这篇文章主要介绍了php5.3提示Function ereg() is deprecated Error问题解决方法,主要是由于php5.3对ereg()函数升级造成的,使用时只要对其规则和函数进行简单的修改即可,需要的朋友可以参考下2014-11-11PHP下编码转换函数mb_convert_encoding与iconv的使用说明
mb_convert_encoding这个函数是用来转换编码的。原来一直对程序编码这一概念不理解,不过现在好像有点开窍了。2009-12-12windows下zendframework项目环境搭建(通过命令行配置)
本文将详细介绍windows下通过命令行配置zendframework项目环境,需要了解的朋友可以参考下2012-12-12
最新评论