PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法
程序员文章站
2022-06-20 23:45:02
本文实例讲述了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程序设计有所帮助。
推荐阅读
-
php提示Warning:mysql_fetch_array() expects的解决方法
-
php5.3提示Function ereg() is deprecated Error问题解决方法
-
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO
-
php提示Call-time pass-by-reference has been deprecated in的解决方法[已测]
-
PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法
-
php后台经常提示无法连接mysql 刷新后又可以访问的解决方法
-
The mysql extension is deprecated and will be removed in the future,这是什么原因啊解决方法
-
PHP提示Deprecated: mysql_connect(): The mysql extension is dep_PHP
-
php5.3提示Function ereg() is deprecated Error问题解决方法,eregdeprecated_PHP教程
-
php提示Call-time pass-by-reference has been deprecated in的解决方法[已测]_php实例