<? 
include "mysql_cnstr.php"; 
 
// In this page we use a constructor. At this point the database connection is 
// already available. You can easily include mysql_cnstr.php at the beginning 
// of each php script that must access a MySql database and you will find 
// yourself with a ready-to-use database connection 
 
// Execute a simple query 
 
$query = 'select Host, User, Password from user'; 
if ($db->Query($query)) 
{ 
    echo '<pre>'; 
    echo 'Database: ' . $db->dbname . "\n"; 
    echo 'Query: ' . $query . "\n\n"; 
 
    // Show the results 
    while ($row = $db->NextRow()) 
    { 
        printf("%s\t%s\t%s\n", $row['Host'], $row['User'], $row['Password']); 
    } 
     
    echo '</pre>'; 
} 
else echo "Query error: " . $db->get_Error();    // Print error message if necessary 
 
// Close db connection 
$db->Close(); 
?>
 
 |