During the Php+mysql development process, the following prompts are encountered:
Deprecated:mysql_connect (): The MySQL extension is Deprecated and would be a removed in the Future:use mysqli or PDO Instea D
For the development environment, the APACH,PHP,MYSQL is installed separately and the integration environment is not used, and the version is as follows:
php--5.6.3;
Mysql--5.6.21-log;
Using mysqli instead of MySQL, the code is as follows.
Original MySQL part code:
1 //connecting to a database2 $connection=mysql_connect("127.0.0.1:3306", "root", "root") or die("Can not Connnect".Mysql_errno());3 4 //set encoding format to prevent garbled page display5 //mysql_query (' Set names UTF8 ', $connection);6 7 //Select Database8 mysql_select_db("My_wiki",$connection);9 Ten //Querying the database One $sql= "SELECT * from category"; A $result=mysql_query($sql);
The corresponding MYSQLI code:
1 //connecting to a database2 $connection=NewMysqli ("172.25.5.79:3306", "root", "root", "Discuz");3 4 //set encoding format to prevent garbled page display5 $connection->query ("SET NAMES UTF8");6 7 //Querying the database8 $sql= "SELECT * from category";9 $result=$connection->query ($sql);
PHP Development uses mysqli instead of MySQL