Common commands for PHP database operations, common commands for php database _ PHP Tutorial

Source: Internet
Author: User
Common commands for PHP database operations and common commands for php databases. Common commands for PHP database operations and common commands for php databases? Php sets the character set header (content-type: texthtml; charsetutf8); connects to the database and determines whether the database is successful or not $ link common commands for PHP database operations, common commands for php databases
 0) {echo 'query succeeded ';} else {echo 'query failed';} // closes the database connection mysql_close (); // The common PHP database operation command require, include // use the function to include a file in mysql_connect ('localhost', 'root', 'root') // connect to the database mysql_select_db ('database name ') // select database mysql_set_charset ('utf8') // set the character set mysql_errno () // error code mysql_error () // error message mysql_query ('SQL statement ') // if the SQL statement is executed successfully, the system returns the resource. if the SQL statement fails, the system returns falsemysql_free_result ($ result). // releases the resource mysql_close () // closes the database mysql_affected_rows ($ link) // returns the number of affected rows. when adding, modifying, and deleting rows, you can determine mysql_insert_id ($ link). // if the auto-increment id in the table is successfully added, this function returns the auto-increment idmysql_num_rows ($ result) // It is only used to query the number of records in the returned result set. mysql_fetch_array ($ result) // return the records in the result set in the form of an array to understand the mixed array. then mysql_fetch_row ($ result) // return the records in the result set to the index array in the form of an array. For more information, see mysql_fetch_assoc ($ result). // return the records in the result set to the associated array in the form of an array.

Why? Php // set the character set header ("content-type: text/html; charset = utf8"); // connect to the database and determine whether the connection is successful. $ link =...

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.