PHP Classes

File: example1.php

Recommend this page to a friend!
  Classes of Alessio Maria Braccini  >  mysqlc  >  example1.php  >  Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: Example script (without constructor)
Class: mysqlc
MySQL database access wrapper
Author: By
Last change:
Date: 16 years ago
Size: 876 bytes


Class file image Download
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)
"Database connection not available");

// Execute a simple query

$query = 'select Host, User, Password from user';
if (
'Database: ' . $db->dbname . "\n";
'Query: ' . $query . "\n\n";

// Show the results
while ($row = $db->NextRow())
printf("%s\t%s\t%s\n", $row['Host'], $row['User'], $row['Password']);
else echo
"Query error: " . $db->get_Error(); // Print error message if necessary

// Close db connection

For more information send a message to info at phpclasses dot org.