dbquery() sends an unique query to the database.
Quote
dbquery ( string $query )
<?php
$result = dbquery('SELECT * WHERE 1=1');
if (!$result) {
die('Invalid query: ' . mysql_error());
}
?>
<?php
// This could be supplied by a user, for example
$firstname = 'fred';
$lastname = 'fox';
// Formulate and Prefom Query
// This is the best way to perform a SQL query
// For more examples, see dbarray()
$result = dbquery("SELECT firstname, lastname, address, age
FROM friends WHERE firstname='$firstname' AND lastname='$lastname'");
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "n";
$message .= 'Whole query: ' . $query;
die($message);
}
// Use result
// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), dbarraynum(), etc.
while ($row = dbarray($result)) {
echo $row['firstname'];
echo $row['lastname'];
echo $row['address'];
echo $row['age'];
}
// Free the resources associated with the result set
// This is done automatically at the end of the script
mysql_free_result($result);
?>