PHP Development uses mysqli instead of MySQL

Source: Internet
Author: User
Tags deprecated

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:



Using mysqli instead of MySQL, the code is as follows.

Original MySQL part code:

1 //connecting to a database2 $connection=mysql_connect("", "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 ("", "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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.