This commit is contained in:
Gnieark 2015-11-29 08:19:06 +01:00
parent f3ad6a9ee1
commit fec759b4b9
2 changed files with 6 additions and 13 deletions

View File

@ -66,7 +66,7 @@ switch ($_POST['act']){
OR (($map['0-2']==$map['1-1'])&&($map['1-1']==$map['2-0'])&&($map['2-0']!=="")) OR (($map['0-2']==$map['1-1'])&&($map['1-1']==$map['2-0'])&&($map['2-0']!==""))
){ ){
echo "<p>".$playerName." ".$playerCHAR." a gagné.</p>"; echo "<p>".$playerName." ".$playerCHAR." a gagné.</p>";
save_battle('tictactoe',$bot1,$bot2,$playerPlayingNow); save_battle('tictactoe',$bots[$bot1]['name'],$bots[$bot2]['name'],$playerPlayingNow);
$end=true; $end=true;
break; break;
} }
@ -80,7 +80,7 @@ switch ($_POST['act']){
} }
if($full){ if($full){
echo "<p>Match nul</p>"; echo "<p>Match nul</p>";
save_battle('tictactoe',$bot1,$bot2,0); save_battle('tictactoe',$bots[$bot1]['name'],$bots[$bot2]['name'],0);
$end=true; $end=true;
break; break;
} }

View File

@ -101,18 +101,12 @@ function error($code,$message){
} }
function conn_bdd(){ function conn_bdd(){
require (__DIR__."/config.php"); require (__DIR__."/config.php");
$mysqlParams=array(
'host' => 'localhost',
'user' => '',
'pass' => '',
'database'=>''
);
if (!$linkMysql=mysqli_connect($mysqlParams['host'], $mysqlParams['user'], $mysqlParams['pass'])) { if (!$linkMysql=mysqli_connect($mysqlParams['host'], $mysqlParams['user'], $mysqlParams['pass'])) {
error(500,'database connexion failed'); error(500,'database connexion failed');
die; die;
} }
mysqli_select_db($linkMysql,$mysqlParams['mysql_database']); mysqli_select_db($linkMysql,$mysqlParams['database']);
mysqli_set_charset($linkMysql, 'utf8'); mysqli_set_charset($linkMysql, 'utf8');
return $linkMysql; //does PHP can do that? 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 //chercher les id de bot 1 et bot2
$rs=mysqli_query($lnMysql,"SELECT name,id FROM bots $rs=mysqli_query($lnMysql,"SELECT name,id FROM bots
WHERE name='".mysqli_real_escape_string($lnMysql,$bot1)."' 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)){ while($r=mysqli_fetch_row($rs)){
$bots[$r[0]]=$r[1]; $bots[$r[0]]=$r[1];
} }