Build Your Own DatabaseDriven Website Using PHP amp;amp; MySQL [Electronic resources]

Kevin Yank

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

mysql_db_query

mysql_db_query(db_name, sql_query[, link_id])

This function selects the MySQL database identified by db_name as if with mysql_select_db, and then executes the specified MySQL query (sql_query). 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.

The function name mysql may also be used, but is deprecated.

Note

As of PHP 4.0.6, this function is deprecated. Use mysql_select_db and then mysql_query, or use only mysql_query and fully specify your table names in your query as dbname.tblname in your query.