Table of Contents

Syntax

resource mysql_db_query(string $database, string $query [, resource $res])

(PHP 4, PHP 5)

$database The name of the database to select before the query is run.
$query An SQL query to be run on the database server.
$res The MySQL database connection resource (returned by a call to mysql_connect.
RETURNS A database query result resource. You may call the mysql_fetch… functions to read the data rows.

What it Does

Peforms a query ($query) against the specified database ($database). Unlike, mysql_query, this function allows you to specify a database to use (in the event that more than one database is available to the user on the connection.)

Example

// open the mysql resource
$res = mysql_connect($server, $user, $pass);
 
// the query to run
$sql = 'SELECT * FROM tblState';
 
// run a 'select' on the 'system' database
$data = mysql_db_query('system', $sql, $res);