Je fait un jeu est dans mon jeu on peut faire évoluer sa mine , quand je développe ma mine elle gagne un niveau et après je faire perdre les ressources as la session "metal" de l'utilisateur puis je lès enleve de la base de données sauf que le niveau passe bien mais quand je veut enlever des ressources a la base de données c'est impossible merci de m'aider :
<?php
session_start();
if (isset ($_POST['new_name']) AND isset($_POST['renommer']))
{
// On rénomme la planete
try
{
$bdd = new PDO('mysql:host=localhost;dbname=new_time', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
// On modifie le nom de la planete
$bdd->exec('UPDATE user SET name_planete =\'' . $_POST['new_name'] . '\' WHERE user =\'' . $_SESSION['pseudo'] . '\'');
echo 'Le nom a bien été modifié !';
echo"</br> <a href='game.php'>Retour</a>";
}
elseif (isset ($_POST['mine_m_new']))
{
if ($_SESSION['mine_m_lvl'] == $_SESSION['level_max_m'])
{
echo "Votre mine à atteind son niveau maximum";
}
elseif($_SESSION['metal'] < $_SESSION['metal_n_m'] OR $_SESSION['cristal'] < $_SESSION['cristal_n_m'] OR $_SESSION['kryptonite'] < $_SESSION['kryptonite_n_m'])
{
echo "Vous n'avez pas assez de ressource !";
}
else
{
//On
try
{
$bdd = new PDO('mysql:host=localhost;dbname=new_time', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
// On ajoute un niveau à la mine
$_SESSION['mine_m_lvl'] = $_SESSION['mine_m_lvl'] + 1 ;
$bdd->exec('UPDATE user SET mine_m_lvl =' . $_SESSION['mine_m_lvl'] . ' WHERE user =\'' . $_SESSION['pseudo'] . '\'');
$_SESSION['metal'] = $_SESSION['metal'] - $_SESSION['metal_n_m'] ;
$_SESSION['cristal'] = $_SESSION['cristal'] - $_SESSION['cristal_n_m'] ;
$_SESSION['kryptonite'] = $_SESSION['kryptonite'] - $_SESSION['kryptonite_n_m'] ;
// On enlève les ressources nécessaires
$bdd->exec('UPDATE user SET metal =' . $_SESSION['metal'] . 'cristal=' . $_SESSION['cristal'] . 'kryptonite=' . $_SESSION['kryptonite'] . ' WHERE user =\'' . $_SESSION['pseudo'] . '\'');
echo 'Votre mine à bien évolué jusqu\'au niveau ' . $_SESSION['mine_m_lvl'] . ' !';
echo"</br> <a href='game.php'>Retour</a>";
}
}
else
{
echo " Raté ";
}
?>
Cordialement Rayon-gamaP.S : Ceci m'affiche aucune erreur et bien le texte normal .