PHP uses MySQL to connect MySQL database with mysqli

Source: Internet
Author: User
Tags deprecated php mysql

The code is simple and straight up.

<?PHP/** * @Author: HTL * @Email: [Email protected] * @DateTime: 2015-05-14 16:00:08 * @Description : Description*/    //lower the default error level for PHP//Show only all errors except disable//resolves a deprecation warning "deprecated:mysql_connect (): The MySQL extension is Deprecated and would when using mysql_connect because the php5.3+ version is too high be removed in the Future:use mysqli or PDO instead "Error_reporting (e_all ^e_deprecated); $db _host="localhost"; $db _user="Root"; $db _passwd=""; $db _name="MySQL"; Echo ("<BR>---------------------------mysql_connect------------------------<BR><BR>"); $query="SELECT Session_user (), Current_User (), now ();"; $conn=mysql_connect ($db _host, $db _user, $db _passwd); if(!$conn) {Die ('Could not connect:'. Mysql_error ());    } mysql_select_db ($db _name, $conn); $result=mysql_query ($query);  while($row =mysql_fetch_array ($result))    {var_dump ($row);    } mysql_close ($conn); Echo ("<BR>---------------------------mysqli_connect------------------------<BR><BR>"); $conn=Mysqli_connect ($db _host, $db _user, $db _passwd, $db _name); if(!$conn) {Die ('Could not connect:'. Mysqli_error ()); }    //execute the query.$result =mysqli_query ($conn, $query); //Display information:     while($row =Mysqli_fetch_array ($result))     {var_dump ($row);    } mysqli_close ($conn);    Exit (); ?>

there 's a picture of the truthReference: Fix Deprecated:mysql_connect (): The MySQL extension is deprecated and would be removed in the Future:use mysqli or PDO i Nstead inw3school PHP MySQL selectphp manual error_reporting



From for notes (Wiz)



PHP uses MySQL to connect MySQL database with mysqli

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: info-contact@alibabacloud.com 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.