Précédent   Forum des professionnels en informatique > PHP > Langage > Débuter
Débuter Forum d'entraide pour débuter en PHP. Avant de poster -> Cours PHP, FAQ PHP, Outils PHP, etc.
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 21/02/2011, 18h04   #1
Futur Membre du Club
 
Inscription : avril 2009
Messages : 60
Détails du profil
Informations forums :
Inscription : avril 2009
Messages : 60
Points : 15
Points : 15
Par défaut Pb avec la commande mysql_fetch_assoc()

Bonjour à tous,

J'ai créer le code suivant :
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
 
include("librairies/connexion.php");
 
$sql_annonce1 ='SELECT * 
				FROM annonce';
$req_annonce1 = mysql_query($sql_annonce1) or die('Erreur SQL !<br />'.$sql_annonce1.'<br />'.mysql_error());
 
$row = mysql_fetch_assoc($sql_annonce1);
 
print("<tr>"); 
while ($row) 
{ 
$annonce_id = $row['AC_ID'];
$annonce_nom_zone = $row['ZN_LIB'];
$annonce_nom_categorie = $row['CT_LIB'];
$annonce_titre = $row['AC_TITRE'];
$annonce_design = $row['AC_Design'];	
 
print ("<td>$annonce_id</td>
<td>$annonce_nom_zone</td>
<td>$annonce_nom_categorie</td>
<td>$annonce_titre</td>
<td>$annonce_design</td>");
 
}
print("</tr>");
A l'exécution de ce code, j'obtient le message d'erreur suivant :

"Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\TestMapGrece\test1.php on line 10".

La ligne en question est : $row = mysql_fetch_assoc($sql_annonce1).

J'ai regardé dans différents forums mais je n'ai rien trouvé.
Pouvez-vous m'aider svp ?

Merci
Dimitri.
dimitri13 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/02/2011, 18h34   #2
Membre régulier
 
Inscription : novembre 2010
Messages : 102
Détails du profil
Informations forums :
Inscription : novembre 2010
Messages : 102
Points : 86
Points : 86
Salut,

Par hasard c'est pas plutôt:

Code :
$row = mysql_fetch_assoc($req_annonce1);
?
Soull est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/02/2011, 19h08   #3
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 126
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 126
Points : 7 270
Points : 7 270
Bonsoir,

+1Soull,
Avec ton code, tu n'afficheras qu'une seule annonce .
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$req_annonce1 = mysql_query($sql_annonce1) or die('Erreur SQL !<br />'.$sql_annonce1.'<br />'.mysql_error());
while ($row = mysql_fetch_assoc($req_annonce)) 
{ 
	$annonce_id = $row['AC_ID'];
	$annonce_nom_zone = $row['ZN_LIB'];
	$annonce_nom_categorie = $row['CT_LIB'];
	$annonce_titre = $row['AC_TITRE'];
	$annonce_design = $row['AC_Design'];	
	echo "<tr><td>$annonce_id</td>
	<td>$annonce_nom_zone</td>
	<td>$annonce_nom_categorie</td>
	<td>$annonce_titre</td>
	<td>$annonce_design</td></tr>";
}
A+.
andry.aime 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 13h02.


 
 
 
 
Partenaires

Hébergement Web