PHP prompts Deprecated: mysql_connect (): The mysql extension is deprecated solution, deprecated
The example in this article describes The solution for PHP prompt Deprecated: mysql_connect (): The mysql extension is deprecated, which is often encountered in PHP program development. The 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 as connection MySQL user name */'Password',/* The password to use to connect to MySQL password */'World '); /* The default database to query Connection database name */if (! $ Link) {printf ("Can't connect to MySQL Server. Errorcode: % s", mysqli_connect_error (); exit ;}
I hope this article will help you with PHP programming.
Mysql_connect (): The mysql extension is deprecated
I can't hear the Rainbow or the sun.
How can I disable the function when I call the function of PHP MYSQL?
Write error_reporting (E_ALL & ~ at the top of php &~ E_DEPRECATED); ignore errors