<?php
/***************************************************************************
connexion.php - description
-------------------
copyright : (C) 2002 by Cédric Rochat
email : hide@address.com
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
require ("util.php");
if (!isset ($FichierConnexion))
{
$FichierConnexion = 1;
// Fonction Connexion: connexion à MySQL
function Connexion ($pNom,$pMotPasse,$pBase,$pServeur)
{
// Connexion au serveur
$connexion = mysql_pconnect ($pServeur,$pNom,$pMotPasse);
// Petit contrôle de connexion
if (!$connexion)
{
echo "Désolé, connexion au serveur $pServeur impossible\n";
exit;
}
// Connexion à la base
if (!mysql_select_db ($pBase, $connexion))
{
echo "Désolé, accès à la base $pBase impossible\n";
echo "<B>Message de MySQL :</B> " . mysql_error($connexion);
exit;
}
// On renvoie la variable de connexion
return $connexion;
} // Fin de la fonction
} // Fin du test sur $FichierConnexion
?>