PHP Classes
elePHPant
Icontem

File: example1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 9 years ago
Size: 876 bytes
 

Contents

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)
    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();
?>