Build Your Own Database-Driven Website Using PHP MySQL [Electronic resources]

Kevin Yank

نسخه متنی -صفحه : 190/ 167
نمايش فراداده

mysql_query

mysql_query(sql_query[, link_id])

This function executes the specified MySQL query (sql_query) on the currently selected database.

If the MySQL connection identifier (link_id) is not specified, PHP will use the currently active connection. If no such connection exists, PHP will attempt to open a connection by implicitly calling mysql_connect with default parameters.

If the query fails, an error message to that effect will be displayed unless '@' is added to the beginning of the function name, and the function will return false instead of a result identifier (which evaluates to true). If the error occurred due to an error in the SQL query, the error number and message can be obtained using mysq_errno and mysql_error respectively.