PHP Classes

File: installDatabase.php

Recommend this page to a friend!
  Classes of Andrew   News Script   installDatabase.php   Download  
File: installDatabase.php
Role: Auxiliary script
Content type: text/plain
Description: Installation file
Class: News Script
Manage and publish news stored in a MySQL database
Author: By
Last change:
Date: 15 years ago
Size: 950 bytes
 

Contents

Class file image Download
<?php
/********************************************

    InstallDatabase.php

    This script will create the required MySQL
    Table for use with the News System.

*********************************************/

/**
 * Connect to DB here!!
 */
// Import Database settings etc.
require('config.php');

$connection = mysql_connect($db_host, $db_user, $db_password)
                            or die(
"Unable to connect to MySQL");
                           
mysql_select_db($db_name, $connection) or die("Unable to select DB!");


$sql = 'CREATE TABLE `newstbl` ('
       
. ' `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, '
       
. ' `author` VARCHAR(30) NOT NULL, '
       
. ' `content` TEXT NOT NULL, '
       
. ' `date` DATE NOT NULL'
       
. ' )'
       
. ' ENGINE = myisam;';


if(
mysql_query($sql))
{
    echo
"Table created, Success!";
}
else echo
"Error creating table! Maybe you forgot to edit the config file?!";

mysql_close($connection);

?>