PHP Classes

File: example2.php

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


Class file image Download
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 (
'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.