From 3bf8d8ce5523414265d5d7a6eba9860c0f8e0767 Mon Sep 17 00:00:00 2001 From: gnieark Date: Mon, 30 Nov 2015 00:16:01 +0100 Subject: [PATCH] =?UTF-8?q?la=20connexion=20mysql=20devien=20globale=20?= =?UTF-8?q?=C3=A0=20tout=20le=20site=20(finalement=20j'aurai=20plusieurs?= =?UTF-8?q?=20appels=20par=20page)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/index.php | 2 +- src/functions.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/html/index.php b/html/index.php index ba8fd82..8898833 100644 --- a/html/index.php +++ b/html/index.php @@ -13,7 +13,7 @@ @session_start(); require_once("../src/functions.php"); - +$lnMysql=conn_bdd(); $arenas=get_arenas_list(); $lang=get_language_array(); diff --git a/src/functions.php b/src/functions.php index c778b74..ed2e61f 100644 --- a/src/functions.php +++ b/src/functions.php @@ -112,8 +112,9 @@ function conn_bdd(){ } function get_battles_history($game){ + global $lnMysql; $game=substr($game,0,8); //limit 8 char for limitting mysql index size - $lnMysql=conn_bdd(); + $rs=mysqli_query($lnMysql, " SELECT player1.name, @@ -142,15 +143,16 @@ function get_battles_history($game){ ); } - mysqli_close($lnMysql); return $results; } function save_battle($game,$bot1,$bot2,$resultat){ //resultat: 0 match nul, 1 bot1 gagne 2 bot 2 gagne + global $lnMysql; + $game=substr($game,0,8); //limit 8 char for limitting mysql index size - $lnMysql=conn_bdd(); + //chercher les id de bot 1 et bot2 $rs=mysqli_query($lnMysql,"SELECT name,id FROM bots WHERE name='".mysqli_real_escape_string($lnMysql,$bot1)."' @@ -186,6 +188,4 @@ function save_battle($game,$bot1,$bot2,$resultat){ '".$bots[$bot2]."', '1') ON DUPLICATE KEY UPDATE ".$field." = ".$field." + 1;"); - - mysqli_close($lnMysql); }