diff --git a/src/arenas/tictactoe/act.php b/src/arenas/tictactoe/act.php index 015765a..38e919e 100644 --- a/src/arenas/tictactoe/act.php +++ b/src/arenas/tictactoe/act.php @@ -66,7 +66,7 @@ switch ($_POST['act']){ OR (($map['0-2']==$map['1-1'])&&($map['1-1']==$map['2-0'])&&($map['2-0']!=="")) ){ echo "

".$playerName." ".$playerCHAR." a gagné.

"; - save_battle('tictactoe',$bot1,$bot2,$playerPlayingNow); + save_battle('tictactoe',$bots[$bot1]['name'],$bots[$bot2]['name'],$playerPlayingNow); $end=true; break; } @@ -80,7 +80,7 @@ switch ($_POST['act']){ } if($full){ echo "

Match nul

"; - save_battle('tictactoe',$bot1,$bot2,0); + save_battle('tictactoe',$bots[$bot1]['name'],$bots[$bot2]['name'],0); $end=true; break; } @@ -102,4 +102,4 @@ switch ($_POST['act']){ break; default: break; -} \ No newline at end of file +} diff --git a/src/functions.php b/src/functions.php index a09cd99..fe4b7f0 100644 --- a/src/functions.php +++ b/src/functions.php @@ -101,18 +101,12 @@ function error($code,$message){ } function conn_bdd(){ require (__DIR__."/config.php"); - $mysqlParams=array( - 'host' => 'localhost', - 'user' => '', - 'pass' => '', - 'database'=>'' - ); if (!$linkMysql=mysqli_connect($mysqlParams['host'], $mysqlParams['user'], $mysqlParams['pass'])) { error(500,'database connexion failed'); die; } - mysqli_select_db($linkMysql,$mysqlParams['mysql_database']); + mysqli_select_db($linkMysql,$mysqlParams['database']); mysqli_set_charset($linkMysql, 'utf8'); return $linkMysql; //does PHP can do that? @@ -125,8 +119,7 @@ function save_battle($game,$bot1,$bot2,$resultat){ //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)."' - OR name='".mysqli_real_escape_string($lnMysql,$bot2)."'"); - + OR name='".mysqli_real_escape_string($lnMysql,$bot2)."'"); while($r=mysqli_fetch_row($rs)){ $bots[$r[0]]=$r[1]; } @@ -160,4 +153,4 @@ function save_battle($game,$bot1,$bot2,$resultat){ ON DUPLICATE KEY UPDATE ".$field." = ".$field." + 1;"); mysqli_close($lnMysql); -} \ No newline at end of file +}