《PHP教程:PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法》要点:
本文介绍了PHP教程:PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法,希望对您有用。如果有疑问,可以联系我们。
PHP教程本文实例讲述了PHP提示 Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法,在PHP程序开发中常会遇到这类问题.分享给大家供大家参考,具体的解决方法如下:
PHP教程将下面代码改为mysqli或PDO即可.
PHP教程
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']);
}
PHP教程PDO:
PHP教程
$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
PHP教程MYSQLI:
PHP教程
$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程序设计有所帮助.
维易PHP培训学院每天发布《PHP教程:PHP提示Deprecated: mysql_connect(): The mysql extension is deprecated的解决方法》等实战技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培养人才。