<?php
	
		$site = $_SERVER["SERVER_NAME"];
		
		if( ($site == "localhost") || ($site == "127.0.0.1") ) 
		{
			$db_host    = "localhost";
			$db_user   = "root";
			$db_pass   = ""; 
			$db_name   = "test";
			echo "localhost";
		}
	
		else 
		{
		   $db_host    = "analogdepat.mysql.db";
   	       $db_user   = "analogdepat";
 	       $db_pass   = "Un92pac007";
	       $db_name   = "analogdepat";
		 }
 
		//$con = mysqli_connect($host, $user, $pwd, $db);
		$con = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
 
		if(mysqli_connect_errno($con)) 
		{
			die("Failed to connect to MySQL: " . mysqli_connect_error());
		} 
   
   
    $sql = "INSERT INTO infos_tbl(id, jeu, v1, v2, v3, v4) VALUES('', 'coco' ,'nom','prenom','email','icq')";
    
    // on insère les informations du formulaire dans la table
    mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error()); 
/* 
		$fileHandle = fopen("liste_jeux.csv", "r");
 
		while (($row = fgetcsv($fileHandle, 0, ";")) !== FALSE) 
		{
			echo 'Nom: ' . $row[0] . '<br>';
			echo '# de joueurs min: ' . $row[1] . '<br>';
			echo '# de joueurs max: ' . $row[2] . '<br>';
			echo 'Durée min: ' . $row[3] . '<br>';
			echo 'durée max: ' . $row[4] . '<br>';
			echo 'Age: ' . $row[5] . '<br>';
			echo '<br>';
			echo '<br>';
			echo '<br>';
			
			$query = "INSERT INTO table_jeux (id, jeu, joueur_min, joueur_max, duration_min, duration_max, age) VALUES ('', '$row[0]', '$row[1]', '$row[2]', '$row[3]', '$row[4]', '25')";

			echo $query;
			echo "<br>";
		
			$result = mysql_query($query);
			
			if (!$result)
			{
				die('Requête invalide : ' . mysql_error());
			}
			
	
		}
*/	
	 mysql_close();  // on ferme la connexion 

/*	 
	CREATE TABLE table_jeux
	(
		id int unsigned NOT NULL AUTO_INCREMENT,
		jeu varchar(100) NOT NULL,
		joueur_min int unsigned NOT NULL default 0,
		joueur_max int unsigned NOT NULL default 0,
		duration_min int unsigned NOT NULL default 0,
		duration_max int unsigned NOT NULL default 0,
		age int unsigned NOT NULL default 0,
		primary key(id)
	);
	
	
	CREATE TABLE infos_tbl 
	(
		id INT (11) not null AUTO_INCREMENT, 
		jeu VARCHAR (35) not null , 
		v1 VARCHAR (35) not null , 
		v2 VARCHAR (35) not null , 
		v3 VARCHAR (35) not null , 
		v4 VARCHAR (35) not null , 
		PRIMARY KEY (id)
	)	
	
*/
	
?>