Fatal error : Cannot execute query....
Lucryio
Messages postés
224
Statut
Membre
-
jordane45 Messages postés 40051 Date d'inscription Statut Modérateur Dernière intervention -
jordane45 Messages postés 40051 Date d'inscription Statut Modérateur Dernière intervention -
Bonjour,
Je viens vous voir car, j'ai cette erreur :
voici mon code :
Si vous avez des idées, je suis preneur ;)
la ligne qui me dis qui pose problème est celle-ci :
Je viens vous voir car, j'ai cette erreur :
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.' in /home/u978416698/public_html/Jeu/pages/peche.php:122 Stack trace: #0 /home/u978416698/public_html/Jeu/pages/peche.php(122): PDO->exec('DELETE FROM mem...') #1 /home/u978416698/public_html/Jeu/index.php(226): include('/home/u97841669...') #2 {main} thrown in /home/u978416698/public_html/Jeu/pages/peche.php on line 122
voici mon code :
<?php
// ICI la partie PHP de ta page
// (les variables, le traitement du submit, les requêtes.... )
//------------------------------------------------------------------------//
if(!empty($ID))
{
$map = "Nazaris";
?>
<div id="curseur" class="infobulle"></div>
<table style="border:0px; padding:0px; margin:0px;">
<tr>
<td>
<?php
$meteomania = $bdd->query("SELECT * FROM meteo");
$meteo = $meteomania->fetch();
if($meteo['temps'] == 'pluie'){
$tps = "pluvieux";
}else if($meteo['temps'] == 'brume'){
$tps = "brumeux";
}else{
$tps = "bleu";}
if($heure >= 7 && $heure < 20){
echo '<img src="images/contenu/soleil.png"/>';
$periode = "jour";
}else{
echo '<img src="images/contenu/lune.png"/>';
$periode = "nuit";}
?>
</td>
<td>
Il est <b><?php echo $heure2; ?></b>. Il fait <b><?php echo $periode; ?></b> à <b><?php echo $map; ?></b>.<br />
La température est estimée à <b><?php echo $meteo['degre']; ?></b>°C sous un ciel <b><?php echo $tps; ?></b>.
</td>
</tr>
</table><br /><br />
<?php
if($map == 'Nazaris') /* On utilise le fichier index2.php pour rediriger le membre vers sa localisation */{
if($heure >= 7 && $heure < 20){
if($tps == "pluvieux"){
echo '<img src="images/maps/'.$map.'_pluie.gif"
Usemap="#'.$map.'" style="overflow: scroll;border: 1px solid black;"/>';
$sql45 = $bdd->query("SELECT * FROM peche_jour_pluie WHERE map='Nazaris' AND temps='pluie' ORDER BY RAND()");
}else if($tps == "brumeux"){
echo '<img src="images/maps/'.$map.'_brume.png"
Usemap="#'.$map.'" style="overflow: scroll;border: 1px solid black;"/>';
$sql45 = $bdd->query("SELECT * FROM peche_jour_brume WHERE map='Nazaris' AND periode3='brume' ORDER BY RAND()");
}else{
echo '<img src="images/maps/'.$map.'.png"
Usemap="#'.$map.'" style="overflow: scroll;border: 1px solid black;"/>';
$sql45 = $bdd->query("SELECT * FROM peche WHERE map='Nazaris' AND periode='jour' ORDER BY RAND()");}
?>
<map name="<?php echo $map; ?>">
<?php
}else{
if($tps == "pluvieux")
{ echo '<img src="images/maps/nuit/'.$map.'_pluie.gif"
Usemap="#'.$map.'" style="overflow: scroll;border: 1px solid black;"/>';
$sql45 = $bdd->query("SELECT * FROM peche_nuit_pluie WHERE map='Nazaris' AND periode5='pluie' ORDER BY RAND()");
}else if($tps == "brumeux"){
echo '<img src="images/maps/nuit/'.$map.'_brume.png"
Usemap="#'.$map.'" style="overflow: scroll;border: 1px solid black;"/>';
$sql45 = $bdd->query("SELECT * FROM peche_nuit_brume WHERE map='Nazaris' AND periode3='brume' ORDER BY RAND()");
}else{
echo '<img src="images/maps/nuit/'.$map.'.png"
Usemap="#'.$map.'" style="overflow: scroll;border: 1px solid black;"/>';
$sql45 = $bdd->query("SELECT * FROM peche WHERE map='Nazaris' AND periode2='nuit' ORDER BY RAND()");}
?>
<map name="<?php echo $map; ?>">
<?php } include("coords.php");
?>
</map></br></br>
<?php
}else{
echo '<b><font color="red">Erreur de localisation. Cette map n\'existe pas.</font></b><br /><br />
Si cette erreur <b>persiste</b> :<br />
Veuillez contacter <b>l\'Administration</b> pour vous déplacer sur une autre map.';}
} // Fin du if($map == 'Nazaris')
//----------------------------------------------------------------------------------//
//requêtes
//----------------------------------------------------------------------------------//
$sql4 = $bdd->query("SELECT COUNT(*) FROM membres_objets WHERE membre_id='".$ID."' AND ID_objet = '5'")->fetchColumn();
if ($sql4 == 1)
{
$rrd = $bdd->query("UPDATE pages_vues SET peche = peche + 1");
$nbr = 1;
$s = $bdd->query("SELECT COUNT(*) FROM membres_objets WHERE membre_id='".$ID."' AND ID_objet='1'")->fetchColumn();
$sq = $bdd->query("SELECT COUNT(*) FROM membres_objets WHERE membre_id='".$ID."' AND ID_objet='2'")->fetchColumn();
$sqlo = $bdd->query("SELECT COUNT(*) FROM membres_objets WHERE membre_id='".$ID."' AND ID_objet='3'")->fetchColumn();
$sqle = $bdd->query("SELECT COUNT(*) FROM membres_objets WHERE membre_id='".$ID."' AND ID_objet='4'")->fetchColumn();
//----------------------------------------------------------------------------------//
// Taux de capture
//----------------------------------------------------------------------------------//
$taux_capture1 = rand(1 , 100);
$taux_capture2 = rand(1 , 100);
$taux_capture3 = rand(1 , 100);
$taux_capture4 = rand(1 , 100);
$taux1 = $taux_capture1;
$taux2 = $taux_capture2;
$taux3 = $taux_capture3;
$taux4 = $taux_capture4;
//---------------------------------------------------------------------------------//
//----------------------------------------------------------------------------------//
// Variables POST
//----------------------------------------------------------------------------------//
$OK = !empty(nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode($_POST['selec_ball'])))))) ? nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode($_POST['cap_poke']))))) : '';
$choix=!empty(nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode($_POST['selec_ball'])))))) ? nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode($_POST['selec_ball']))))) : NULL;
$select_id_poke_affichage = $bdd->exec("SELECT * FROM pokemon_peche WHERE id AND capture='0' ORDER BY duree DESC LIMIT 1");
$pv = ($select_id_poke_affichage['niveau'] * 2);
$pv_max = ($select_id_poke_affichage['niveau'] * 4);
$exp_max = ($select_id_poke_affichage['niveau'] * 1000);
// Traitement du choix
$sql = $bdd->exec("DELETE FROM membres_objets WHERE membre_id=:'".$ID."' AND ID_objet='".$choix."' LIMIT 1");
switch($choix){
case '1':
if ($taux1 <= 20){
$insert_pok = $bdd->prepare("INSERT INTO transfertspokemon VALUES('', :ID, :pok, :niveau, :pv, :pv_max, '0', :exp_max,:sexe, '0', :shiney, '', :time, 'Nazaris', '7', '0', '', '', '', :pokeball)");
$insert_pok -> bindvalue(':ID', $ID);
$insert_pok -> bindvalue(':pok', $select_id_poke_affichage['no']);
$insert_pok -> bindvalue(':niveau', $select_id_poke_affichage['niveau']);
$insert_pok -> bindvalue(':pv', $pv);
$insert_pok -> bindvalue(':pv_max', $pv_max);
$insert_pok -> bindvalue(':exp_max', $exp_max);
$insert_pok -> bindvalue(':sexe', $select_id_poke_affichage['sexe']);
$insert_pok -> bindvalue(':shiney', $select_id_poke_affichage['shiney']);
$insert_pok -> bindvalue(':time', $select_id_poke_affichage['time']);
$insert_pok -> bindvalue(':pokeball', $choix);
$insert_pok -> execute();
$msg = "Bravo ! Tu as capturé ce pokemon ! ";?>
<script> alert('Bravo ! Tu as capturé ce pokemon !'); </script><meta http-equiv="refresh" content="0;url="/>
<?php
}else{
$msg = "Dommage le pokemon c'est enfuie";?>
<script> alert('Dommage, le pokemon c\'est enfuie !'); </script><meta http-equiv="refresh" content="0;url="/>
<?php
}
break;
case '2':
if ($taux2 <= 50){
$insert_pok = $bdd->prepare("INSERT INTO transfertspokemon VALUES('', :ID, :pok, :niveau, :pv, :pv_max, '0', :exp_max,:sexe, '0', :shiney, '', :time, 'Nazaris', '7', '0', '', '', '', :pokeball)");
$insert_pok -> bindvalue(':ID', $ID);
$insert_pok -> bindvalue(':pok', $select_id_poke_affichage['no']);
$insert_pok -> bindvalue(':niveau', $select_id_poke_affichage['niveau']);
$insert_pok -> bindvalue(':pv', $pv);
$insert_pok -> bindvalue(':pv_max', $pv_max);
$insert_pok -> bindvalue(':exp_max', $exp_max);
$insert_pok -> bindvalue(':sexe', $select_id_poke_affichage['sexe']);
$insert_pok -> bindvalue(':shiney', $select_id_poke_affichage['shiney']);
$insert_pok -> bindvalue(':time', $select_id_poke_affichage['time']);
$insert_pok -> bindvalue(':pokeball', $choix);
$insert_pok -> execute();
$msg = "Bravo ! Tu as capturé ce pokemon ! ";?>
<script> alert('Bravo ! Tu as capturé ce pokemon !'); </script><meta http-equiv="refresh" content="0;url="/>
<?php
}else{
$msg = "Dommage le pokemon c'est enfuie";?>
<script> alert('Dommage, le pokemon c\'est enfuie !'); </script><meta http-equiv="refresh" content="0;url="/>
<?php
}
break;
case '3':
if ($taux3 <= 80){
$insert_pok = $bdd->prepare("INSERT INTO transfertspokemon VALUES('', :ID, :pok, :niveau, :pv, :pv_max, '0', :exp_max,:sexe, '0', :shiney, '', :time, 'Nazaris', '7', '0', '', '', '', :pokeball)");
$insert_pok -> bindvalue(':ID', $ID);
$insert_pok -> bindvalue(':pok', $select_id_poke_affichage['no']);
$insert_pok -> bindvalue(':niveau', $select_id_poke_affichage['niveau']);
$insert_pok -> bindvalue(':pv', $pv);
$insert_pok -> bindvalue(':pv_max', $pv_max);
$insert_pok -> bindvalue(':exp_max', $exp_max);
$insert_pok -> bindvalue(':sexe', $select_id_poke_affichage['sexe']);
$insert_pok -> bindvalue(':shiney', $select_id_poke_affichage['shiney']);
$insert_pok -> bindvalue(':time', $select_id_poke_affichage['time']);
$insert_pok -> bindvalue(':pokeball', $choix);
$insert_pok -> execute();
$msg = "Bravo ! Tu as capturé ce pokemon ! ";?>
<script> alert('Bravo ! Tu as capturé ce pokemon !'); </script><meta http-equiv="refresh" content="0;url="/>
<?php
}else{
$msg = "Dommage le pokemon c'est enfuie";?>
<script> alert('Dommage, le pokemon c\'est enfuie !'); </script><meta http-equiv="refresh" content="0;url="/>
<?php
}
break;
case '4':
if ($taux4 <=100) {
$insert_pok = $bdd->prepare("INSERT INTO transfertspokemon VALUES('', :ID, :pok, :niveau, :pv, :pv_max, '0', :exp_max,:sexe, '0', :shiney, '', :time, 'Nazaris', '7', '0', '', '', '', :pokeball)");
$insert_pok -> bindvalue(':ID', $ID);
$insert_pok -> bindvalue(':pok', $select_id_poke_affichage['no']);
$insert_pok -> bindvalue(':niveau', $select_id_poke_affichage['niveau']);
$insert_pok -> bindvalue(':pv', $pv);
$insert_pok -> bindvalue(':pv_max', $pv_max);
$insert_pok -> bindvalue(':exp_max', $exp_max);
$insert_pok -> bindvalue(':sexe', $select_id_poke_affichage['sexe']);
$insert_pok -> bindvalue(':shiney', $select_id_poke_affichage['shiney']);
$insert_pok -> bindvalue(':time', $select_id_poke_affichage['time']);
$insert_pok -> bindvalue(':pokeball', $choix);
$insert_pok -> execute();
$msg = "Bravo ! Tu as capturé ce pokemon ! ";?>
<script> alert('Bravo ! Tu as capturé ce pokemon !'); </script><meta http-equiv="refresh" content="0;url="/>
<?php
}else{
$msg = "Dommage le pokemon c'est enfuie";?>
<script> alert('Dommage, le pokemon c\'est enfuie !'); </script><meta http-equiv="refresh" content="0;url="/>
<?php
}
break;
default:
$msg ='';
}
?>
<table>
<tr>Venez pêcher toutes sortes de Pokemon aquatique. Certains d'entre eux peuvent même être Shiney</tr></br>
<tr>
<?php
//Récupération "propre" des variables
while(($don = $sql45->fetch()) && ($nbr <= 1)){
$nbr++;
$sexe = rand(1,2);
if ($sexe == 1){
$sexe2 = 'Male';
}elseif ($sexe == 2) {
$sexe2 = 'Femelle';
}else {
$sexe = '';
}
if($map == "Nazaris"){
$niveau = rand(2,5);}
$randshiney = rand(1,4096);
if($randshiney == 1){
$shiney2 = "Shiney";?><img src="http://pokemon-history.com/etoile.png"/><?php
}else{
$shiney2 = "";
}
$time=time();
$insert_poke_table_capture = $bdd->prepare("INSERT INTO pokemon_peche VALUES ('',:no_poke, :niveau_poke, :sexe, :shiney, :map, :capture, :time)");
$insert_poke_table_capture->bindValue(':no_poke', $don['no'], PDO::PARAM_INT);
$insert_poke_table_capture->bindValue(':niveau_poke', $niveau, PDO::PARAM_INT);
$insert_poke_table_capture->bindValue(':sexe', $sexe, PDO::PARAM_INT);
$insert_poke_table_capture->bindValue(':shiney', $randshiney, PDO::PARAM_INT);
$insert_poke_table_capture->bindValue(':map', $map, PDO::PARAM_STR);
$insert_poke_table_capture->bindValue(':capture', '0', PDO::PARAM_INT);
$insert_poke_table_capture->bindValue(':time', $time, PDO::PARAM_INT);
$insert_poke_table_capture->execute();
} //fin du while
if (isset($OK)) { // on affiche si le formulaire a été validé.
echo $msg;
}
$select_id_poke_affichage = $bdd->exec("SELECT * FROM pokemon_peche WHERE id AND capture='0' ORDER BY time DESC LIMIT 1");
?>
<td>
<img src="<?php echo nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode(utf8_decode($url)))))); ?>images/pokemon/<?php echo nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode(utf8_decode($shiney)))))); ?>/<?php echo nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode(utf8_decode($don['no'])))))); ?>.gif"/>
<br>
<?php echo nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode(utf8_decode($don['nom'])))))); ?></b>
<span style="color: <?php echo nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode(utf8_decode($color_shiney)))))); ?>;">
<?php echo $shiney2; ?>
</span>
<br>
<b>Niveau <?php echo nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode(utf8_decode($niveau)))))); ?>
</b>
<br>
<b>Sexe</b> : <?php echo nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode(utf8_decode($sexe2)))))); ?></br>
<b>Type : <img src="images/type/<?php echo nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode(utf8_decode($don['type']))))));?>.png" />
<img src="images/type/<?php echo nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode(utf8_decode($don['type2']))))));?>.png" />
</b>
<form action="" method="POST"><br/>
<input type="hidden" value="<?php echo nl2br(stripslashes(htmlentities(htmlspecialchars(html_entity_decode(utf8_decode($select_id_poke_affichage['id'])))))); ?>" name="id_poke_capture"/>
<select name="selec_ball">
<?php
if ($s >= 1 ){
?>
<option value="1"> PokeBall (<?php echo $s ; ?>)</option>
<?php
}
if ($sq >= 1 ){
?>
<option value="2"> SuperBall (<?php echo $sq ; ?>) </option>
<?php
}
if ($sqlo >= 1 ){
?>
<option value="3"> HyperBall (<?php echo $sqlo ; ?>) </option>
<?php
}
if ($sqle >= 1 ){
?>
<option value="4"> MasterBall (<?php echo $sqle ; ?>) </option>
<?php
}
?>
</select>
<br>
<input type="submit"
value="Capturer !"
name="cap_poke"
style="cursor:pointer; padding:5px 20px; background-color:gold; border-radius:15px;"> </form>
</td>
</tr>
</table>
<?php
}
else { echo 'Vous n\'avez pas de canne à pêche';}
Si vous avez des idées, je suis preneur ;)
la ligne qui me dis qui pose problème est celle-ci :
$sql = $bdd->exec("DELETE FROM membres_objets WHERE membre_id=:'".$ID."' AND ID_objet='".$choix."' LIMIT 1");
A voir également:
- Fatal error : Cannot execute query....
- Fan error lenovo - Forum Refroidissement
- Cmos checksum error ✓ - Forum Carte-mère/mémoire
- Error 1962 ✓ - Forum PC fixe
- Eespt technical error ✓ - Forum TNT / Satellite / Réception
- Bad request error 403 paiement ✓ - Forum Réseaux sociaux
1 réponse
Bonjour,
Commence par faire du méngage dans ton code... il est imbitable en l'état!
Par exemple :
ceci :
Peut se faire en UNE seule requête du genre :
Ensuite... dans ton SWITCH CASE .... là encore ... tu copîe/colle 4 fois la même requête...
.... pourquoi ??
Alors que rien (même pas le message qui se trouve en dessous) ne varie... ????
Moins tu feras d'appels à ta BDD .. mieux c'est !
Et pour finir, si ton souci persiste après ce "ménage" .. tu peux toujours regarder du côté de closeCursor()
Commence par faire du méngage dans ton code... il est imbitable en l'état!
Par exemple :
ceci :
$s = $bdd->query("SELECT COUNT(*) FROM membres_objets WHERE membre_id='".$ID."' AND ID_objet='1'")->fetchColumn();
$sq = $bdd->query("SELECT COUNT(*) FROM membres_objets WHERE membre_id='".$ID."' AND ID_objet='2'")->fetchColumn();
$sqlo = $bdd->query("SELECT COUNT(*) FROM membres_objets WHERE membre_id='".$ID."' AND ID_objet='3'")->fetchColumn();
$sqle = $bdd->query("SELECT COUNT(*) FROM membres_objets WHERE membre_id='".$ID."' AND ID_objet='4'")->fetchColumn();
Peut se faire en UNE seule requête du genre :
$sql = "SELECT COUNT(*)
FROM membres_objets
WHERE membre_id=:id
GROUP BY ID_objet";
$a_datas = array(":id"=>$ID);
$prepare = $bdd->prepare($sql);
$prepare->execute($a_datas);
//on stocke le resultat dans un array
$arr_result = $prepare->fetchAll();
Ensuite... dans ton SWITCH CASE .... là encore ... tu copîe/colle 4 fois la même requête...
$insert_pok = $bdd->prepare("INSERT INTO transfertspokemon VALUES('', :ID, :pok, :niveau, :pv, :pv_max, '0', :exp_max,:sexe, '0', :shiney, '', :time, 'Nazaris', '7', '0', '', '', '', :pokeball)");
$insert_pok -> bindvalue(':ID', $ID);
$insert_pok -> bindvalue(':pok', $select_id_poke_affichage['no']);
$insert_pok -> bindvalue(':niveau', $select_id_poke_affichage['niveau']);
$insert_pok -> bindvalue(':pv', $pv);
$insert_pok -> bindvalue(':pv_max', $pv_max);
$insert_pok -> bindvalue(':exp_max', $exp_max);
$insert_pok -> bindvalue(':sexe', $select_id_poke_affichage['sexe']);
$insert_pok -> bindvalue(':shiney', $select_id_poke_affichage['shiney']);
$insert_pok -> bindvalue(':time', $select_id_poke_affichage['time']);
$insert_pok -> bindvalue(':pokeball', $choix);
$insert_pok -> execute();
.... pourquoi ??
Alors que rien (même pas le message qui se trouve en dessous) ne varie... ????
Moins tu feras d'appels à ta BDD .. mieux c'est !
Et pour finir, si ton souci persiste après ce "ménage" .. tu peux toujours regarder du côté de closeCursor()