Login   Register  
PHP Classes
elePHPant
Icontem

File: create_test_db.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of ian james  >  User Auth Mgr  >  create_test_db.php  >  Download  
File: create_test_db.php
Role: Auxiliary script
Content type: text/plain
Description: create test DB
Class: User Auth Mgr
Create and manage user records in a MySQL database
Author: By
Last change:
Date: 2010-10-08 22:11
Size: 803 bytes
 

Contents

Class file image Download
<?php

require_once (dirname(__FILE__) .  "/config.php");

$dbhost=$GLOBALS['dbhost'];
$dbuser=$GLOBALS['dbuser'];
$dbpass=$GLOBALS['dbpass'];
$database=$GLOBALS['dbname'];

$link mysql_connect($dbhost,$dbuser,$dbpass);
if (!
$link) {
    die(
'Could not connect: ' mysql_error());
}
echo 
"Connected successfully\n";

/* DROP existing database
 */
$sql =  "DROP DATABASE IF EXISTS $database";
if (
mysql_query($sql$link)) {
    echo 
"Database '$database' dropped successfully\n";
} else {
    echo 
'Error dropping database: ' mysql_error() . "\n";
}   

/* CREATE database
 */
$sql "CREATE DATABASE $database";
if (
mysql_query($sql$link)) {
    echo 
"Database '$database' created successfully\n";
} else {
    echo 
'Error creating database: ' mysql_error() . "\n";
}

mysql_close($link);

?>