PHP - Undefined variable

JBennn Messages postés 92 Date d'inscription   Statut Membre Dernière intervention   -  
vordano Messages postés 1685 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

J'ai un problème j'ai effacé ma base de donnée et j'en ai refais une, le problème c'est que mtn logiquement mon code ne fonctionne plus, j'ai essayé de régler ce que je pouvais mais j'ai encore des erreurs et je ne vois pas comment les corriger.. pouvez-vous m'aider svp ?

Voici mes erreurs :
Notice: Undefined variable: clubdomicile in C:\xampp\htdocs\Footclic\pagematch.php on line 89

Notice: Undefined variable: clubexterieur in C:\xampp\htdocs\Footclic\pagematch.php on line 101

Notice: Undefined variable: clubdomicile in C:\xampp\htdocs\Footclic\pagematch.php on line 109
:
Notice: Undefined variable: afficheVoteD in C:\xampp\htdocs\Footclic\pagematch.php on line 109

Match nul :
Notice: Undefined variable: afficheVoteN in C:\xampp\htdocs\Footclic\pagematch.php on line 111


Notice: Undefined variable: clubexterieur in C:\xampp\htdocs\Footclic\pagematch.php on line 113
:
Notice: Undefined variable: afficheVoteE in C:\xampp\htdocs\Footclic\pagematch.php on line 113

Voici mon code :

<?php include ("header.php");?>

<div style="clear:both"></div>

<div id="content">

	<form action="" method="post">  

		<div id="pronosinternautes"> 
		<?php
		   if (isset($match['club_D']) && isset($match['club_E'])){
			$monSqlVote="SELECT COUNT(idProno) AS nombre FROM prono WHERE adresseIp = \"{$_SERVER['REMOTE_ADDR']}\" AND idMatch = {$_GET['idMatch']}";
				$prono=mysql_query($monSqlVote) or die(mysql_error());

			$monSql="SELECT * FROM matchs WHERE idMatch= {$_GET['idMatch']}";
				$match=mysql_fetch_array(mysql_query($monSql));

			$monSqlD="SELECT * FROM equipe WHERE equipe.idEquipe={$match['club_D']}";
			$monSqlE="SELECT * FROM equipe WHERE equipe.idEquipe={$match['club_E']}";
				$clubdomicile=mysql_query($monSqlD);	 
				$clubexterieur=mysql_query($monSqlE);

			$monSqlVoteD="SELECT COUNT(idProno) AS nombreVoteD FROM prono, equipe, matchs WHERE equipe.idEquipe = prono.idEquipe AND prono.idMatch = matchs.idMatch AND equipe.idEquipe={$match['club_D']}";
			$monSqlVoteN="SELECT COUNT(idProno) AS nombreVoteN FROM prono WHERE prono.idEquipe = 0";
			$monSqlVoteE="SELECT COUNT(idProno) AS nombreVoteE FROM prono, equipe, matchs WHERE equipe.idEquipe = prono.idEquipe AND prono.idMatch = matchs.idMatch AND equipe.idEquipe={$match['club_E']}";
				$afficheVoteD=mysql_fetch_array(mysql_query($monSqlVoteD)) or die (mysql_error());
				$afficheVoteN=mysql_fetch_array(mysql_query($monSqlVoteN)) or die (mysql_error());
				$afficheVoteE=mysql_fetch_array(mysql_query($monSqlVoteE)) or die (mysql_error());
			
			if (isset($_POST['divcoche']) && !empty($_POST['divcoche'])){

				switch ($_POST['divcoche']){

					case "prono1":
					$idclubinsert = $clubdomicile['idEquipe'];
					break;

					case "pronoN":
					$idclubinsert = 0;
					break;

					case "prono2":
					$idclubinsert = $clubexterieur['idEquipe'];
					break;	

				}
				if ($prono['nombre'] == 0){

					$voteEquipe ="INSERT INTO prono VALUES('', '".$idclubinsert."', '". date('Y-m-d H:i:s') ."', '". $_SERVER["REMOTE_ADDR"]."', '".$_GET['idmatch']."')";
					mysql_query($voteEquipe) or die (mysql_error()); 
				?>
				<script type="text/javascript">alert("Votre pronostic a bien été pris en compte");</script>
				<?php
						

				}

				else{
				?>
				<script type="text/javascript">alert("Vous avez déjà pronostiqué sur ce match");</script>
				<?php

				}
			}
		}
		?>
				<table>

					<tr>

						<td colspan="3" style="color: #454545; background-color:#d7d3d3; font-weight:bold;">Pronostics des internautes</td>

					</tr>

					<tr>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;">Votre pronostic</td>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;">Score</td>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;">Internautes</td>

					</tr>

					<tr>

						<td>

							<?php echo $clubdomicile['nomEquipe'];?>

							<div style="display:inline-block;">

							<div id="prono1" onclick="activate('prono1')">1</div>

							<div id="pronoN" onclick="activate('pronoN')">N</div>

							<div id="prono2" onclick="activate('prono2')">2</div>

							</div>

							<?php echo $clubexterieur['nomEquipe'];?>

						</td> 

						<td></td>

						<td>

							<?php echo $clubdomicile['nomEquipe'];?> : <?php echo $afficheVoteD['nombreVoteD']; ?></br>

							Match nul : <?php echo $afficheVoteN['nombreVoteN'];?></br>

							<?php echo $clubexterieur['nomEquipe']; ?> : <?php echo $afficheVoteE['nombreVoteE']; ?></br>

						</td>

					</tr>

					<tr>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;">

						<input style="display:none;" type="submit" id="boutonOK" value="OK"/>

						<input type="hidden" name="divcoche" id="divcoche" value=""  />

						</td>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;"></td>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;"></td>

					</tr>

				</table>

		</div>

	</form>

</div>







<script type="text/javascript">

function activate(idDiv){

    //Désactivation de la div 1

     desactivate("prono1");

	 desactivate("pronoN");

	 desactivate("prono2");

	//activation de la dernière div

	document.getElementById(idDiv).style.border = "1px solid white";

	document.getElementById(idDiv).style.backgroundColor = "grey";

	document.getElementById(idDiv).style.color = "white";

	document.getElementById("boutonOK").style.display = "block";

	document.getElementById("divcoche").value = idDiv;

}

function desactivate(idDiv){

	document.getElementById(idDiv).style.border = "1px solid black";

	document.getElementById(idDiv).style.backgroundColor = "white";

	document.getElementById(idDiv).style.color = "black";				

}

</script>





<?php include ("footer.php");?>


A voir également:

4 réponses

Kommu
 
Tu as vérifier que tu n'avais pas d'erreur dans la casse des champs entre ton scripts et ta base de données ?
0
JBennn Messages postés 92 Date d'inscription   Statut Membre Dernière intervention   1
 
Oui j'ai vérifié :s

Ma table equipe :

IdEquipe
nomEquipe
pays

ma table matchs:
idMatch
domicile
exterieur
dateMatch
score

ma table prono :
idProno
idEquipe
dateProno
adresseIp
idMatch
0
Kommu
 
La connexion à la base de donnée aussi je suppose tu as revérifier, aussi.

Si j'ai un peu de temps je reregarderais mieux, sinon quelqu'un de plus compétent te répondra avant ;)
0
vordano Messages postés 1685 Date d'inscription   Statut Membre Dernière intervention   316
 
je suppose que tu comptais écrire idEquipe au lieu de IdEquipe :)

de plus le mysql_query est sensé renvoyer un jeu d'enregistrement a parcourir avec un mysql_fetch_array non ? donc tu t'es ptete trompé a la ligne 20 et 21
0
JBennn Messages postés 92 Date d'inscription   Statut Membre Dernière intervention   1
 
Oui pardon idEquipe ^^

J'ai rajouté un mysql_fetch_array aux lignes 20 et 21 mais toujours les mêmes erreurs
0
Kommu
 
le $match[] tu le sort d'où ? j'arrive pas a voir :s
0
JBennn Messages postés 92 Date d'inscription   Statut Membre Dernière intervention   1
 
Je vous explique correctement lol

J'ai une page prono.php, dans cette page j'ai une liste deroulante avec des dates. Quand je sélectionne une date j'ai les matchs de cette date qui s'affichent. Lorsque je clique sur un match, ça m'ammène sur pagematch.php et là je peux pronostiquer sur ce match ( 1 / N ou 2 )

Voici mon code prono.php :

<?php include ("header.php");?>

<div id="actu">
	<form id="formdate" method="POST" action="">
		DATE
			<select name="dateMatch">
				<?php

				$debut= new DateTime("last monday");
				$fin= new DateTime("monday");

				$MonSql5 = 'SELECT * 
							FROM matchs
							WHERE dateMatch > "'.$debut->format('Y-m-d').'"
							AND dateMatch < "'.$fin->format('Y-m-d').'"';

				$resultat=mysql_query($MonSql5) or die (mysql_error()); 
					while ($donnees=mysql_fetch_array($resultat)){
						$dateMatch=$donnees['dateMatch'];
				?>
						<option value="<?php echo $donnees['dateMatch'];?>" <?php if(isset($_POST['dateMatch'])) { if ($_POST['dateMatch']==$donnees['dateMatch']){?> selected="selected" <?php } } ?>><?php echo $donnees['dateMatch'];?> </option>
					<?php 
					} 
					?>
			</select>
		<input type="submit" value="OK"/>

	</form>

<div id="tableau">

<h3 style="background-color:grey;">Euro 2012</h3>
<?php if (isset($_POST['dateMatch'])){

$MonSql6="SELECT * FROM matchs WHERE dateMatch='".$_POST['dateMatch']."' ";

$req=mysql_query($MonSql6) or die (mysql_error());
	while($data=mysql_fetch_array($req)){

		$clu_D = mysql_fetch_array(mysql_query("SELECT * FROM equipe, matchs WHERE idEquipe = '". $data['domicile'] ."'"));

		$clu_E = mysql_fetch_array(mysql_query("SELECT * FROM equipe, matchs WHERE idEquipe = '". $data['exterieur'] ."'"));



		$domicile=$data['domicile'];

		$exterieur=$data['exterieur'];

		$score=$data['score'];

		$dateMatch=$data['dateMatch'];

?>
<table>
	<tbody>
	<tr>
		<td class="t1"><?php echo $data['dateMatch']; ?></td>
			<td class="t2"><?php echo $score; ?></td> 
			<td class="t3"><a id="lienparier" href="pagematch.php?idMatch=<?php echo $data['idMatch'];?>">Pariez</a></td>
			<td class="t4"><?php echo $clu_D['nomEquipe']; ?></td>
			<td class="t5"> - </td>
			<td class="t6"><?php echo $clu_E['nomEquipe']; ?></td>
			
		</tr>
	</tbody>
<?php 

	}	
}
?>
</table>
</div>
</div>

<?php include ("footer.php");?>


Voici ma pagematch.php:
<?php include ("header.php");?>

<div style="clear:both"></div>

<div id="content">

	<form action="" method="post">  

		<div id="pronosinternautes"> 
		<?php
		   if (isset($match['club_D']) && isset($match['club_E'])){
			$monSqlVote="SELECT COUNT(idProno) AS nombre FROM prono WHERE adresseIp = \"{$_SERVER['REMOTE_ADDR']}\" AND idMatch = {$_GET['idMatch']}";
				$prono=mysql_query($monSqlVote) or die(mysql_error());

			$monSql="SELECT * FROM matchs WHERE idMatch= {$_GET['idMatch']}";
				$match=mysql_fetch_array(mysql_query($monSql));

			$monSqlD="SELECT * FROM equipe WHERE equipe.idEquipe={$match['club_D']}";
			$monSqlE="SELECT * FROM equipe WHERE equipe.idEquipe={$match['club_E']}";
				$clubdomicile=mysql_fetch_array(mysql_query($monSqlD));	 
				$clubexterieur=mysql_fetch_array(mysql_query($monSqlE));

			$monSqlVoteD="SELECT COUNT(idProno) AS nombreVoteD FROM prono, equipe, matchs WHERE equipe.idEquipe = prono.idEquipe AND prono.idMatch = matchs.idMatch AND equipe.idEquipe={$match['club_D']}";
			$monSqlVoteN="SELECT COUNT(idProno) AS nombreVoteN FROM prono WHERE prono.idEquipe = 0";
			$monSqlVoteE="SELECT COUNT(idProno) AS nombreVoteE FROM prono, equipe, matchs WHERE equipe.idEquipe = prono.idEquipe AND prono.idMatch = matchs.idMatch AND equipe.idEquipe={$match['club_E']}";
				$afficheVoteD=mysql_fetch_array(mysql_query($monSqlVoteD)) or die (mysql_error());
				$afficheVoteN=mysql_fetch_array(mysql_query($monSqlVoteN)) or die (mysql_error());
				$afficheVoteE=mysql_fetch_array(mysql_query($monSqlVoteE)) or die (mysql_error());
			
			if (isset($_POST['divcoche']) && !empty($_POST['divcoche'])){

				switch ($_POST['divcoche']){

					case "prono1":
					$idclubinsert = $clubdomicile['idEquipe'];
					break;

					case "pronoN":
					$idclubinsert = 0;
					break;

					case "prono2":
					$idclubinsert = $clubexterieur['idEquipe'];
					break;	

				}
				if ($prono['nombre'] == 0){

					$voteEquipe ="INSERT INTO prono VALUES('', '".$idclubinsert."', '". date('Y-m-d H:i:s') ."', '". $_SERVER["REMOTE_ADDR"]."', '".$_GET['idmatch']."')";
					mysql_query($voteEquipe) or die (mysql_error()); 
				?>
				<script type="text/javascript">alert("Votre pronostic a bien été pris en compte");</script>
				<?php
						

				}

				else{
				?>
				<script type="text/javascript">alert("Vous avez déjà pronostiqué sur ce match");</script>
				<?php

				}
			}
		}
		?>
				<table>

					<tr>

						<td colspan="3" style="color: #454545; background-color:#d7d3d3; font-weight:bold;">Pronostics des internautes</td>

					</tr>

					<tr>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;">Votre pronostic</td>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;">Score</td>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;">Internautes</td>

					</tr>

					<tr>

						<td>

							<?php echo $clubdomicile['nomEquipe'];?>

							<div style="display:inline-block;">

							<div id="prono1" onclick="activate('prono1')">1</div>

							<div id="pronoN" onclick="activate('pronoN')">N</div>

							<div id="prono2" onclick="activate('prono2')">2</div>

							</div>

							<?php echo $clubexterieur['nomEquipe'];?>

						</td> 

						<td></td>

						<td>

							<?php echo $clubdomicile['nomEquipe'];?> : <?php echo $afficheVoteD['nombreVoteD']; ?></br>

							Match nul : <?php echo $afficheVoteN['nombreVoteN'];?></br>

							<?php echo $clubexterieur['nomEquipe']; ?> : <?php echo $afficheVoteE['nombreVoteE']; ?></br>

						</td>

					</tr>

					<tr>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;">

						<input style="display:none;" type="submit" id="boutonOK" value="OK"/>

						<input type="hidden" name="divcoche" id="divcoche" value=""  />

						</td>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;"></td>

						<td style="color: #454545; background-color:#d7d3d3; font-weight:bold;"></td>

					</tr>

				</table>

		</div>

	</form>

</div>







<script type="text/javascript">

function activate(idDiv){

    //Désactivation de la div 1

     desactivate("prono1");

	 desactivate("pronoN");

	 desactivate("prono2");

	//activation de la dernière div

	document.getElementById(idDiv).style.border = "1px solid white";

	document.getElementById(idDiv).style.backgroundColor = "grey";

	document.getElementById(idDiv).style.color = "white";

	document.getElementById("boutonOK").style.display = "block";

	document.getElementById("divcoche").value = idDiv;

}

function desactivate(idDiv){

	document.getElementById(idDiv).style.border = "1px solid black";

	document.getElementById(idDiv).style.backgroundColor = "white";

	document.getElementById(idDiv).style.color = "black";				

}

</script>





<?php include ("footer.php");?>


et sur pagematch.php il y a toutes ces erreurs :/
0
Kommu
 
$monSql="SELECT * FROM matchs WHERE idMatch= {$_GET['idMatch']}";
$match=mysql_fetch_array(mysql_query($monSql));


Match est rempli ici, alors forcement dans ta condition plus haut :

if (isset($match['club_D']) && isset($match['club_E']))

Cela ne rentre pas dans la boucle
0
Kommu
 
De plus dans la base matches il n'y as pas club_D et club_E il y a domicile et exterieur
0
JBennn Messages postés 92 Date d'inscription   Statut Membre Dernière intervention   1
 
Merci effectivement c'était le isset ... Plus d'erreurs ^^ merci beaucoup !

J'aurai un dernier problème à vous montrer.

En faites une personne ne peut pas pronostiquer 2 fois sur le mm match.. avec l'adresse ip

sauf que là j'ai essayé et je peux pourtant il y a bien la condition :

$monSqlVote="SELECT COUNT(idProno) AS nombre FROM prono WHERE adresseIp = \"{$_SERVER['REMOTE_ADDR']}\" AND idMatch = {$_GET['idMatch']}";
				$prono=mysql_query($monSqlVote) or die(mysql_error());



if ($prono['nombre'] == 0){

					$voteEquipe ="INSERT INTO prono VALUES('', '".$idclubinsert."', '". date('Y-m-d H:i:s') ."', '". $_SERVER["REMOTE_ADDR"]."', '".$_GET['idMatch']."')";
					mysql_query($voteEquipe) or die (mysql_error()); 
				?>
				<script type="text/javascript">alert("Votre pronostic a bien été pris en compte");</script>
				<?php
						

				}

				else{
				?>
				<script type="text/javascript">alert("Vous avez déjà pronostiqué sur ce match");</script>
				<?php

				}
			}
0
Kommu
 
Je dois y aller mais essaye de faire

if(mysql_num_rows($prono) == 0) { ...
0
JBennn Messages postés 92 Date d'inscription   Statut Membre Dernière intervention   1
 
arf là sa me prends que le message de mon else :/
0
JBennn Messages postés 92 Date d'inscription   Statut Membre Dernière intervention   1
 
donc je peux plus pronostiquer
0
vordano Messages postés 1685 Date d'inscription   Statut Membre Dernière intervention   316
 
le mysql_num_rows ne s'utilise pas sur un count(*), donc fait juste un select *
0
JBennn Messages postés 92 Date d'inscription   Statut Membre Dernière intervention   1
 
Merci vordano mais a coté de chaque match j'affiche le nombre de prono pr par exemple la FRance , le nombre de prono pour le match nul et le nombre de prono pour l'Ukraine. mais si je mets match nul pour un match , sur tous les autres matchs je vois écrit "1" à coté de match nul .. je sais pas si tu as compris lol
0