1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| <?php
$cfg['db_server'] = 'localhost';
$cfg['db_user_login'] = 'root';
$cfg['db_user_pass'] = '';
$cfg['db_name'] = 'mybase';
$cfg['db_table'] = 'mytable';
$cfg['linkid'] = '';
//==========================================================//
function OpenBase() {
global $cfg;
if(!$cfg['linkid']=@mysql_connect(
$cfg['db_server'],
$cfg['db_user_login'],
$cfg['db_user_pass']))
Die("Erreur lors de la connection à la base de données «".$cfg['db_server']."»!");
@mysql_query('CREATE DATABASE IF NOT EXISTS `'.$cfg['db_name'].'`');
if(!@mysql_select_db(
$cfg['db_name'],
$cfg['linkid']))
Die("Impossible de sélectionner la base de données «".$cfg['db_name']."»!");
$sql='CREATE TABLE IF NOT EXISTS `'.$cfg['db_table'].'` ('.
'`mykey` VARCHAR(255) NOT NULL,'.
'`myfile` VARCHAR(255) NOT NULL,'.
'`mydate` DATE NOT NULL, INDEX (`mykey`));';
@mysql_query($sql);
}
//==========================================================//
function CloseBase() {
global $cfg;
@mysql_close($cfg['linkid']);
unset($cfg['linkid']);
}
//==========================================================//
?> |
Partager