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