PHP database Operations common commands, PHP database common commands
Php//Set character setsHeader("Content-type:text/html;charset=utf8");//connect to the database and determine success or not$link=mysql_connect(' localhost ', ' root ', ' root ') or die(' Connection failed ');//Select Databasemysql_select_db(' Database name ');//Set character setsMysql_set_charset (' UTF8 ');//Preparing SQL statements$sql= "SELECT * from User";//Send SQL statement$result=mysql_query($sql);//determine if the SQL statement executed was successfulif($result&&mysql_affected_rows() >0){ Echo' Query succeeded ';}Else{ Echo' Query failed ';}//To close a database connectionMysql_close();//PHP Database Operations common Commandsrequire,include//use a function to include a file inmysql_connect(' localhost ', ' root ', ' root ')//connecting to a databasemysql_select_db(' Database name ')//Select DatabaseMysql_set_charset (' UTF8 ')//Set character setsMysql_errno()//Error NumberMysql_error()//error Messagemysql_query(' SQL statement ')//Execute SQL statement successfully returns a resource, failure returns falseMysql_free_result($result)//Freeing ResourcesMysql_close()//Close the databasemysql_affected_rows($link)//returns the number of rows affected the general addition of modified Delete when the judgmentmysql_insert_id($link)//If the table has a self-increment ID added successfully, the self-increment ID will be returned through this functionmysql_num_rows($result)//only for queries returning the number of records in the result setMysql_fetch_array($result)//returns a mixed array of records in the result set as an array understandMysql_fetch_row($result)//return the records in the result set as an array to an indexed array.Mysql_fetch_assoc($result)//returning the records in the result set as an array the associated array is recommended and mastered
http://www.bkjia.com/PHPjc/1082220.html www.bkjia.com true http://www.bkjia.com/PHPjc/1082220.html techarticle PHP Database operations commonly used commands, PHP database common commands? PHP//Set the character Set header ("Content-type:text/html;charset=utf8");//Connect the database and determine whether it is successful $link =...