本文实例讲述了PHP提示 Deprecated: MysqL_connect(): The MysqL extension is deprecated的解决方法,在PHP程序开发中常会遇到这类问题。分享给大家供大家参考,具体的解决方法如下:
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']);
}
PDO:
PHP;">
$dbh = new PDO('MysqL:host=localhost;dbname=test',$user,$pass);
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程序设计有所帮助。
原文链接:https://www.f2er.com/php/23873.html