Mysql_fetch_array() expects parameter 1

Fermé
merlyone Messages postés 25 Date d'inscription vendredi 12 mars 2010 Statut Membre Dernière intervention 15 novembre 2011 - 1 nov. 2011 à 00:43
 Gauthier - 8 juin 2020 à 07:28
Bonsoir,
J'ai beau essayé de recupérer et d'afficher les données de la base mais j'obtiens toujours l'erreur "Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in D:\wamp\......" ! je fais donc appel a vous pour avoir la solution voici le code :


<?php

include("connexion.php");
$req ="select email,categorie,code_postal,titre,telephone,description from annonceur where id=105" ;
mysql_query($req) or die('Erreur SQL !'.$req.'<br>'.mysql_error());


while($lignes=mysql_fetch_array($req))
{
$email = $lignes["email"];
$categorie = $lignes["categorie"];
$CP = $lignes["code_postal"];
$titre = $lignes["titre"];
$tel = $lignes["telephone"];
$desciption = $lignes["description"];
$photo = $lignes["photo"];
}


echo'<tr>
<td> Email: $email; </td> //Affichage des valeurs
<td>categorie: $categorie; </td>
<td> code postal: $CP; </td>
<td> titre: $titre; </td>
<td> telephone: $tel; </td>
<td> description: $description; </td>
<td> photo: $photo; </td>
</tr>'

?>

1 réponse

jojo673 Messages postés 210 Date d'inscription lundi 19 septembre 2011 Statut Membre Dernière intervention 9 avril 2014 44
1 nov. 2011 à 01:18
mysql_fetch_array() prend comme paramètre la réponse de mysql_query(), hors ici une requête est passé en paramètre... il faut donc faire :
$reponse = mysql_query($req) or die('Erreur SQL !'.$req.'<br>'.mysql_error());

while($lignes=mysql_fetch_array($reponse))
... 
12
merlyone Messages postés 25 Date d'inscription vendredi 12 mars 2010 Statut Membre Dernière intervention 15 novembre 2011
1 nov. 2011 à 02:57
Merci pour l'aide je vais essayer pou voir si ça marche !
0
merci à toi !!
0
merci beaucoup pour votre réponse et ça m'a beaucoup aidé
0