Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 28/05/2011, 11h02   #1
Invité de passage
 
Inscription : juin 2008
Messages : 21
Détails du profil
Informations forums :
Inscription : juin 2008
Messages : 21
Points : 2
Points : 2
Par défaut Update SQL qui ne trouve pas mes variables

Bonjour,

Je suis en train d'essayer de faire un site pour mon club de foot avec match, classement ..., je bloque sur la mise à jour des matchs.

J'ai un tableau avec mes matchs, au bout de la ligne, un bouton modifier qui me redirige vers un formulaire :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<fieldset>
					<legend>Mise à jour d'un match</legend>
				<table>
<?php
    $req = $bdd->prepare('
	SELECT match.id AS `match_id`, journee, DATE_FORMAT(date, \'%d/%m/%Y\') AS date, dom.nom AS `dom_nom`, ext.nom AS `ext_nom`,  buts_dom, buts_ext, statut.statut AS `statut_nom`
	FROM `match`, `equipe` AS dom, `equipe` AS ext, `match_statut` AS statut
	WHERE id_equipe_dom=dom.id 
	AND id_equipe_ext=ext.id 
	AND match.id=\'' . $_GET['match_id'] . '\'
	GROUP BY match.id
	');
    $req->execute(array($_GET['match_id']));
	while ($donnees = $req->fetch())
	{
?>
				<form action="update_match.php" method="post">
				<tr>
					<td>
						<label for="match_id">ID du match</label> : 
					</td>
					<td>
						<?php echo ''.$donnees["match_id"].' ';?>
					</td>
				</tr>
				<tr>
					<td>
						<label for="journee">Journée</label> : 
					</td>
					<td>
						<?php echo ''.$donnees["journee"].' ';?>
					</td>
				</tr>
				<tr>
					<td>
						<label for="date">Date</label> : 
					</td>
					<td>
						<input type="text" name="date" id="date" size="10" value="<?php echo ''.$donnees["date"].' ';?>"/>  (exemple 31/07/2011)
					</td>
				</tr>
				<tr>
					<td>
						<label for="dom_nom">Match</label> : 
					</td>
					<td>
						<?php echo ''.$donnees["dom_nom"].' ';?> - <?php echo ''.$donnees["ext_nom"].' ';?>
					</td>
				</tr>
				<tr>
					<td>
						<label for="buts_dom">Score</label> : 
					</td>
					<td>
						<input type="text" name="buts_dom" id="buts_dom" size="3" value="<?php echo ''.$donnees["buts_dom"].' ';?>"/> - <input type="text" name="buts_ext" id="buts_ext" size="3" value="<?php echo ''.$donnees["buts_ext"].' ';?>"/>
					</td>
				</tr>
				<tr>
					<td>
						<label for="statut_nom">Statut</label> : 
					</td>
					<td>
						<select name="statut_nom" id="id_match_statut" value="<?php echo ''.$donnees["statut_nom"].' ';?>"/>
					<option value="1" <?php if ($donnees["statut_nom"] == "1") {echo("selected");}?> >Match à jouer</option>
					<option value="2" <?php if ($donnees["statut_nom"] == "2") {echo("selected");}?> >Match joué</option>
					<option value="3" <?php if ($donnees["statut_nom"] == "3") {echo("selected");}?> >Forfait domicile</option>
					<option value="4" <?php if ($donnees["statut_nom"] == "4") {echo("selected");}?> >Forfait exterieur</option></select>
					</td>
				</tr>
				<tr>
				<td>
                	<a href="admin_match.php"><img src="../images/retour.png" alt="Retour" title="Retour" /></a>
				</td>
				<td>
					<input type="submit" value="Mettre à jour"/>
				</td>
<?php
//On ferme la boucle while
 }
?>
				</table>
			</fieldset>
Le formulaire est bien pré-rempli, j'ai juste à mettre la date, les buts domiciles, extérieur et le statut du match en fonction de l'id du match.

J'ai construit ma page update_match de cette façon :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
	{ 
	       // lancement de la requête
		$req = $bdd->prepare('
		UPDATE match 
		SET date="'.$_POST['date'].'", 
		buts_dom="'.$_POST['buts_dom'].'", 
		buts_ext="'.$_POST['buts_ext'].'", 
		id_match_statut="'.$_POST['id_match_statut'].'"
		WHERE id="'.$_POST['match_id'].'"'); 
 
		$req->execute(array(
		'date' => $_POST['date'], 
		'buts_dom' => $_POST['buts_dom'], 
		'buts_ext' => $_POST['buts_ext'], 
		'id_match_statut' => $_POST['id_match_statut']
		));
 
    // Redirection vers la page d'administration
	header('Location: admin_match.php');
	}   
?>
J'ai les messages :

Citation:
Notice: Undefined index: id_match_statut in F:\wampee\www\xxx\admin\update_match.php on line 23
Notice: Undefined index: match_id in F:\wampee\www\xxx\admin\update_match.php on line 24
Notice: Undefined index: id_match_statut in F:\wampee\www\xxx\admin\update_match.php on line 30
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' in F:\wampee\www\xxx\admin\update_match.php on line 31
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match SET date="28/05/2011 ", buts_dom="0 ", buts_ext="4 ", id_m' at line 1 in F:\wampee\www\xxx\admin\update_match.php on line 31
ça fait deux heures que j'y suis et je ne vois pas le bout

Si quelqu'un à une idée ?
Actraiser est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 28/05/2011, 11h14   #2
Membre confirmé
 
Homme Clément
Développeur informatique
Inscription : décembre 2006
Messages : 213
Détails du profil
Informations personnelles :
Nom : Homme Clément
Localisation : France

Informations professionnelles :
Activité : Développeur informatique

Informations forums :
Inscription : décembre 2006
Messages : 213
Points : 277
Points : 277
Sans trop m'avancer, je crois que tu as mal compris comment fonctionner la méthode "prepare" de PDO (vu ton exception, j'en déduis que tu utilises bien PDO).
Regarde cette page http://php.net/manual/fr/pdo.prepare.php
Il faut mettre des ":variable" et pas "$_POST["variable"]".

Peut être quelque chose dans ce goût là :
Code :
1
2
3
4
5
6
7
8
 
$req = $bdd->prepare('
		UPDATE match 
		SET date= :date, 
		buts_dom= :but_doms, 
		buts_ext= :buts_ext, 
		id_match_statut= :id_match_statut
		WHERE id=:match_id');
Vérifie bien les autres requêtes aussi !
Climoo est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/05/2011, 11h39   #3
Membre éprouvé
 
Avatar de Gecko
 
Homme Antoine B
Développeur Web
Inscription : février 2011
Messages : 106
Détails du profil
Informations personnelles :
Nom : Homme Antoine B
Âge : 27
Localisation : France, Nord (Nord Pas de Calais)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : février 2011
Messages : 106
Points : 409
Points : 409
Envoyer un message via MSN à Gecko Envoyer un message via Skype™ à Gecko
Ta requête est mal formée, en gros il faut faire comme ça pour passer des variables tout en garantissant un minimum de sécurité.

Code php :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
<?php
	{ 
	       // lancement de la requête
                $sql = 'UPDATE match 
                            SET date = :date, 
                                buts_dom = :buts_dom, 
		                buts_ext = :buts_ext, 
		                id_match_statut = :id_match_statut
                            WHERE id = :match_id'
		$req = $bdd->prepare($sql); 
		$req->bindValue(':date',$_POST['date']);
                $req->bindValue(':but_dom',$_POST['buts_dom']);
                $req->bindValue(':but_dom',$_POST['buts_ext']);
                $req->bindValue(':id_match_statut',$_POST['id_match_statut']);
                $req->bindValue(':match_id',$_POST['match_id']);
		$req->execute();
                // Redirection vers la page d'administration
                header('Location: admin_match.php');
	}   
?>

Prend l'habitude de séparer la requête sql de la fonction PDO::prepare() c'est plus propre.

Voici un petit lien vers bindValue(), tu comprendras son utilité ^^

Dernière chose, je ne sais pas si tu l'as fait ici, mais prend l'habitude d'utiliser les blocs try/catch, ça te permettra de mieux gérer les exceptions

Toine
Gecko est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/05/2011, 18h01   #4
Invité de passage
 
Inscription : juin 2008
Messages : 21
Détails du profil
Informations forums :
Inscription : juin 2008
Messages : 21
Points : 2
Points : 2
Oh la la ! vous m'avez complètement perdu, j'ai passé 2h à comprendre mais il doit me manquer quelque chose.

Je pense avoir compris votre principe mais j'ai des nouvelle erreurs

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
	{ 
	       // lancement de la requête
		$req = $bdd->prepare(
		'UPDATE match 
				SET date = :date, 
				buts_dom = :buts_dom, 
				buts_ext = :buts_ext, 
				WHERE id = :match_id'
		); 
		$req->bindValue(':date',$_POST['date']);
		$req->bindValue(':but_dom',$_POST['buts_dom']);
		$req->bindValue(':but_dom',$_POST['buts_ext']);
		$req->bindValue(':match_id',$_POST['match_id']);
		$req->execute();
                // Redirection vers la page d'administration
		header('Location: admin_match.php');
	}   
?>
J'ai l'erreur :

Citation:
( ! ) Notice: Undefined index: match_id in I:\wampee\www\xxx\admin\update_match.php on line 28
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in I:\wampee\www\xxx\admin\update_match.php on line 29
PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in I:\wampee\www\xxx\admin\update_match.php on line 29
Vous avez une idée ?

Je vous remets mon formulaire au cas où

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
			<fieldset>
					<legend>Mise à jour d'un match</legend>
				<table>
<?php
    $req = $bdd->prepare('
	SELECT match.id AS `match_id`, journee, DATE_FORMAT(date, \'%d/%m/%Y\') AS date, dom.nom AS `dom_nom`, ext.nom AS `ext_nom`,  buts_dom, buts_ext, id_match_statut
	FROM `match`, `equipe` AS dom, `equipe` AS ext, `match_statut` AS statut
	WHERE id_equipe_dom=dom.id 
	AND id_equipe_ext=ext.id 
	AND match.id=\'' . $_GET['match_id'] . '\'
	GROUP BY match.id
	');
    $req->execute(array($_GET['match_id']));
	while ($donnees = $req->fetch())
	{
?>
				<form action="update_match.php" method="post">
				<tr>
					<td>
						<label for="match_id">ID du match</label> : 
					</td>
					<td>
						<?php echo ''.$donnees["match_id"].' ';?>
					</td>
				</tr>
				<tr>
					<td>
						<label for="journee">Journée</label> : 
					</td>
					<td>
						<?php echo ''.$donnees["journee"].' ';?>
					</td>
				</tr>
				<tr>
					<td>
						<label for="date">Date</label> : 
					</td>
					<td>
						<input type="text" name="date" id="date" size="10" value="<?php echo ''.$donnees["date"].' ';?>"/>  (exemple 31/07/2011)
					</td>
				</tr>
				<tr>
					<td>
						<label for="dom_nom">Match</label> : 
					</td>
					<td>
						<?php echo ''.$donnees["dom_nom"].' ';?> - <?php echo ''.$donnees["ext_nom"].' ';?>
					</td>
				</tr>
				<tr>
					<td>
						<label for="buts_dom">Score</label> : 
					</td>
					<td>
						<input type="text" name="buts_dom" id="buts_dom" size="3" value="<?php echo ''.$donnees["buts_dom"].' ';?>"/> - <input type="text" name="buts_ext" id="buts_ext" size="3" value="<?php echo ''.$donnees["buts_ext"].' ';?>"/>
					</td>
				</tr>
				<tr>
					<td>
						<label for="id_match_statut">Statut</label> : 
					</td>
					<td>
						<select name="id_match_statut" id="id_match_statut" value="<?php echo ''.$donnees["id_match_statut"].' ';?>"/>
					<option value="1" <?php if ($donnees["id_match_statut"] == "1") {echo("selected");}?> >Match à jouer</option>
					<option value="2" <?php if ($donnees["id_match_statut"] == "2") {echo("selected");}?> >Match joué</option>
					<option value="3" <?php if ($donnees["id_match_statut"] == "3") {echo("selected");}?> >Forfait domicile</option>
					<option value="4" <?php if ($donnees["id_match_statut"] == "4") {echo("selected");}?> >Forfait exterieur</option></select>
					</td>
				</tr>
				<tr>
				<td>
                	<a href="admin_match.php"><img src="../images/retour.png" alt="Retour" title="Retour" /></a>
				</td>
				<td>
					<input type="submit" value="Mettre à jour"/>
				</td>
<?php
//On ferme la boucle while
 }
?>
				</table>
			</fieldset>
Actraiser est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/05/2011, 18h13   #5
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
pourquoi tu fais :
Code :
AND match.id=\'' . $_GET['match_id'] . '\'
et après

Code :
$req->execute(array($_GET['match_id'])
???

y'a un gros soucis la
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/05/2011, 18h31   #6
Invité de passage
 
Inscription : juin 2008
Messages : 21
Détails du profil
Informations forums :
Inscription : juin 2008
Messages : 21
Points : 2
Points : 2
En faite, j'ai un écran précédent qui admin_match.php qui envoi sur le formulaire du match

Code :
<td><?php echo '<a href="admin_update_match.php?match_id=' . htmlspecialchars($donnees['match_id']) . '"><img src="../images/modif_small.png" alt="Modification" title="Modifier le match" /></a>'?></td>
J'arrive donc sur la page admin_update_match.php avec un variable $_GET['match_id']

Code :
$req->execute(array($_GET['match_id'])
me sers à récupérer ma variable pour ma condition.

Code :
AND match.id=\'' . $_GET['match_id'] . '\'
C'est pour que mon select n'affiche que mon match

Je viens de tester en faisant

et ça marche aussi donc effectivement je l'ai mis deux fois pour rien.
Actraiser est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/05/2011, 18h37   #7
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
pourquoi faire une requete préparée si tu ne prépares rien ?
et le problème de sécurité est toujours la...
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/05/2011, 18h58   #8
Invité de passage
 
Inscription : juin 2008
Messages : 21
Détails du profil
Informations forums :
Inscription : juin 2008
Messages : 21
Points : 2
Points : 2
J'ai fait mon update directement sans préparer la requête, juste pour voir si ça marche, je sécuriserais quand ça marcheras.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
	{ 
	       // lancement de la requête
		$bdd->exec(
		'UPDATE match 
				SET date = \'' . $_POST['date'] . '\', 
				buts_dom = \'' . $_POST['buts_dom'] . '\', 
				buts_ext = \'' . $_POST['buts_ext'] . '\',
				id_match_statut = \'' . $_POST['id_match_statut'] . '\'
				WHERE id = \'' . $_POST['match_id'] . '\''
		); 
                // Redirection vers la page d'administration
		header('Location: admin_match.php');
	}   
?>
j'ai les erreurs
Citation:
( ! ) Notice: Undefined index: match_id in F:\wampee\www\xxx\admin\update_match.php on line 24
( ! ) Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' in F:\wampee\www\xxx\admin\update_match.php on line 25
( ! ) PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'match SET date = '31/07/2011', buts_dom = ' 1', buts_ext = '1'' at line 1 in F:\wampee\www\xxx\admin\update_match.php on line 25
Il me trouve bien les données que je rentre pour faire la mise à jour (date, buts_dom et buts_ext mais ni mon match.id, ni mon id_match_statut soit les deux propriétés pour lesquelles j'ai fait un AS dans mon select de la page admin_update_match.php.

Dans mon formulaire POST, j'ai bien les bonne variables :

Code :
1
2
3
4
5
6
					<td>
						<label for="match_id">ID du match</label> : 
					</td>
					<td>
						<?php echo ''.$donnees["match_id"].' ';?>
					</td>
et

Code :
1
2
3
4
5
6
7
					<td>
						<select name="id_match_statut" id="id_match_statut" value="<?php echo ''.$donnees["id_match_statut"].' ';?>"/>
					<option value="1" <?php if ($donnees["id_match_statut"] == "1") {echo("selected");}?> >Match à jouer</option>
					<option value="2" <?php if ($donnees["id_match_statut"] == "2") {echo("selected");}?> >Match joué</option>
					<option value="3" <?php if ($donnees["id_match_statut"] == "3") {echo("selected");}?> >Forfait domicile</option>
					<option value="4" <?php if ($donnees["id_match_statut"] == "4") {echo("selected");}?> >Forfait exterieur</option></select>
					</td>
Actraiser est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 31/05/2011, 19h38   #9
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
vérifie tes données en faisant un print_r($_POST), tu dois échapper les valeurs de ta requete avec PDO::quote
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/05/2011, 20h00   #10
Invité de passage
 
Inscription : juin 2008
Messages : 21
Détails du profil
Informations forums :
Inscription : juin 2008
Messages : 21
Points : 2
Points : 2
Si je fais un print_r, j'obtiens :
Citation:
Array ( [date] => [buts_dom] => 1 [buts_ext] => 1 [id_match_statut] => 1 )
il me manque donc ma variable id.
Le souci c'est que je ne la mets pas dans mon formulaire, je ne fais que l'afficher, comment je peux faire pour la transférer ?
Actraiser est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/06/2011, 00h26   #11
Membre éprouvé
 
Avatar de Gecko
 
Homme Antoine B
Développeur Web
Inscription : février 2011
Messages : 106
Détails du profil
Informations personnelles :
Nom : Homme Antoine B
Âge : 27
Localisation : France, Nord (Nord Pas de Calais)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : février 2011
Messages : 106
Points : 409
Points : 409
Envoyer un message via MSN à Gecko Envoyer un message via Skype™ à Gecko
Citation:
Envoyé par Actraiser Voir le message
Oh la la ! vous m'avez complètement perdu, j'ai passé 2h à comprendre mais il doit me manquer quelque chose.

Je pense avoir compris votre principe mais j'ai des nouvelle erreurs

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
	{ 
	       // lancement de la requête
		$req = $bdd->prepare(
		'UPDATE match 
				SET date = :date, 
				buts_dom = :buts_dom, 
				buts_ext = :buts_ext, 
				WHERE id = :match_id'
		); 
		$req->bindValue(':date',$_POST['date']);
		$req->bindValue(':but_dom',$_POST['buts_dom']);
		$req->bindValue(':but_dom',$_POST['buts_ext']);
		$req->bindValue(':match_id',$_POST['match_id']);
		$req->execute();
                // Redirection vers la page d'administration
		header('Location: admin_match.php');
	}   
?>
J'ai l'erreur :
( ! ) Notice: Undefined index: match_id in I:\wampee\www\xxx\admin\update_match.php on line 28
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in I:\wampee\www\xxx\admin\update_match.php on line 29
PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in I:\wampee\www\xxx\admin\update_match.php on line 29

Vous avez une idée ?

Je vous remets mon formulaire au cas où

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
			<fieldset>
					<legend>Mise à jour d'un match</legend>
				<table>
<?php
    $req = $bdd->prepare('
	SELECT match.id AS `match_id`, journee, DATE_FORMAT(date, \'%d/%m/%Y\') AS date, dom.nom AS `dom_nom`, ext.nom AS `ext_nom`,  buts_dom, buts_ext, id_match_statut
	FROM `match`, `equipe` AS dom, `equipe` AS ext, `match_statut` AS statut
	WHERE id_equipe_dom=dom.id 
	AND id_equipe_ext=ext.id 
	AND match.id=\'' . $_GET['match_id'] . '\'
	GROUP BY match.id
	');
    $req->execute(array($_GET['match_id']));
	while ($donnees = $req->fetch())
	{
?>
				<form action="update_match.php" method="post">
				<tr>
					<td>
						<label for="match_id">ID du match</label> : 
					</td>
					<td>
						<?php echo ''.$donnees["match_id"].' ';?>
					</td>
				</tr>
				<tr>
					<td>
						<label for="journee">Journée</label> : 
					</td>
					<td>
						<?php echo ''.$donnees["journee"].' ';?>
					</td>
				</tr>
				<tr>
					<td>
						<label for="date">Date</label> : 
					</td>
					<td>
						<input type="text" name="date" id="date" size="10" value="<?php echo ''.$donnees["date"].' ';?>"/>  (exemple 31/07/2011)
					</td>
				</tr>
				<tr>
					<td>
						<label for="dom_nom">Match</label> : 
					</td>
					<td>
						<?php echo ''.$donnees["dom_nom"].' ';?> - <?php echo ''.$donnees["ext_nom"].' ';?>
					</td>
				</tr>
				<tr>
					<td>
						<label for="buts_dom">Score</label> : 
					</td>
					<td>
						<input type="text" name="buts_dom" id="buts_dom" size="3" value="<?php echo ''.$donnees["buts_dom"].' ';?>"/> - <input type="text" name="buts_ext" id="buts_ext" size="3" value="<?php echo ''.$donnees["buts_ext"].' ';?>"/>
					</td>
				</tr>
				<tr>
					<td>
						<label for="id_match_statut">Statut</label> : 
					</td>
					<td>
						<select name="id_match_statut" id="id_match_statut" value="<?php echo ''.$donnees["id_match_statut"].' ';?>"/>
					<option value="1" <?php if ($donnees["id_match_statut"] == "1") {echo("selected");}?> >Match à jouer</option>
					<option value="2" <?php if ($donnees["id_match_statut"] == "2") {echo("selected");}?> >Match joué</option>
					<option value="3" <?php if ($donnees["id_match_statut"] == "3") {echo("selected");}?> >Forfait domicile</option>
					<option value="4" <?php if ($donnees["id_match_statut"] == "4") {echo("selected");}?> >Forfait exterieur</option></select>
					</td>
				</tr>
				<tr>
				<td>
                	<a href="admin_match.php"><img src="../images/retour.png" alt="Retour" title="Retour" /></a>
				</td>
				<td>
					<input type="submit" value="Mettre à jour"/>
				</td>
<?php
//On ferme la boucle while
 }
?>
				</table>
			</fieldset>
Si tu regardes ma requête tu verras que je me suis planté en mettant deux fois le même attribut.
Voici la requête comme il faut :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
	{ 
	       // lancement de la requête
		$req = $bdd->prepare(
		'UPDATE match 
				SET date = :date, 
				buts_dom = :buts_dom, 
				buts_ext = :buts_ext, 
				WHERE id = :match_id'
		); 
		$req->bindValue(':date',$_POST['date']);
		$req->bindValue(':buts_dom',$_POST['buts_dom']);
		$req->bindValue(':buts_ext',$_POST['buts_ext']);
		$req->bindValue(':match_id',$_POST['match_id']);
		$req->execute();
                // Redirection vers la page d'administration
		header('Location: admin_match.php');
	}   
?>
Pour l’erreur citée plus haut elle est simple, ça dis que le nombre de paramètres "binValue('xxx',$xxx);" ne correspondes pas entre la requêtes sql et la déclaration dans le script.
Gecko est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 20h15.


 
 
 
 
Partenaires

Hébergement Web