This example describes the PHP hint Deprecated:mysql_connect (): The MySQL extension is deprecated solution, which is often encountered in the development of PHP programs. Share to everyone for your reference, the specific solution is as follows:
Change the following code to MYSQLI or 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 the MySQL address * *
user, * The user to connect a S-connected MySQL username
/' password ',/* The password to use connection to the MySQL password
/' world '); /* The default database to query connects to the DB name *
/if (! $link) {
printf ("Can" T connect to MySQL Server.) ErrorCode:%s ", Mysqli_connect_error ());
Exit;
}
I hope this article will help you with your PHP program design.