<? require "mysqlc.php"; // Include class
// Create a new class instance. Use the right parameters to connect to your // mysql server. "xxx" and "yyy" must be valid username and password for // your MySQL server
$db = new c_mysql("xxx", "yyy", "localhost", "mysql", 2, true);
// Check if the connection is available before going further
if ($db->stat == false) die("Database connection not available");
// 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(); ?>
|