Bonjour,
j'ai un problème dans mon code , j'essaye à inserer certaines informations dans ma base de données, ces infos sont saisies dans un formulaire .
Au premier lieu j'ai réussi à inserer 5 infos , mais quand j'ajoutais des colonnes à ma table une erreur s'affiche comme suit:
"Fatal error: Call to a member function fetchAll() on boolean in C:\wamp64\www\insereannonce.php on line 258"
voici le code :
sql= "INSERT INTO personne(Nom,Email,Telephone,Ville,Quartier,categorie,marque,annee,kilometrage,carosserie,couleur,carburant,transmission,cylindre,P_piscale,
etat_douniaer,description,prix,type_post) VALUES('".(_POST['nom'])."','".(_POST['email'])."','".(_POST['telephone'])."','".(_POST['choix'])."','".(_POST['choix*'])."','".(_POST['choix1'])."','".(_POST['choix2'])."'
,'".(_POST['choix3'])."','".(_POST['choix**'])."','".(_POST['choix4'])."','".(_POST['choix41'])."','".(_POST['choix5'])."','".(_POST['choix51'])."'
,'".(_POST['choix6'])."','".(_POST['choix61'])."','".(_POST['choix7'])."','".(_POST['text2'])."','".(_POST['text'])."','".(_POST['p'])."')";
;
res=conn->query($sql);}
$sql= " SELECT Nom,Email,Telephone,Ville,Quartier , categorie,marque,annee,kilometrage,carosserie,couleur,carburant,transmission,cylindre,P_piscale,
etat_douniaer,description,prix,type_post FROM personne ";
sth=conn->query($sql);
$result= $sth->fetchAll(PDO::FETCH_ASSOC);// ligne de l'erreur
foreach($result as $row){
echo "<tr>";
echo "<td>".$row['Nom']."</td>";
echo "<td>".$row['Email']."</td>";
echo "<td>".$row['Telephone']."</td>";
echo "<td>".$row['Ville']."</td>";
echo "<td>".$row['Quartier']."</td>";
echo "<td>".$row['categorie']."</td>";
echo "<td>".$row['marque']."</td>";
echo "<td>".$row['annee']."</td>";
echo "<td>".$row['kilometrage']."</td>";
echo "<td>".$row['carosserie']."</td>";
echo "<td>".$row['couleur']."</td>";
echo "<td>".$row['carburant']."</td>";
echo "<td>".$row['transmission']."</td>";
echo "<td>".$row['cylindre']."</td>";
echo "<td>".$row['P_piscale']."</td>";
echo "<td>".$row['etat_douniaer']."</td>";
echo "<td>".$row['description']."</td>";
echo "<td>".$row['prix']."</td>";
echo "<td>".$row['type_post']."</td>";
echo "</tr>";
}
echo "<center><table border=4>";
echo "<tr> <th>Nom</th> <th>Email</th> <th>Telephone</th> <th>Ville</th> <th>Quartier</th> <th>categorie</th> <th>marque</th> <th>annee</th>
<th>Kilometrage</th> <th>Carosserie</th> <th>Couleur</th> <th>Carburant</th> <th>Transmission</th> <th>Cylindre</th> <th>P_piscale</th>
<th>Etat_douanier</th> <th>Description</th> <th>Prix</th> <th>Type_post</th> </tr>";
echo "</table></center>";
?>
Veuillez s'ils vous plaît m'aider , j'ai passé toute l'aprés midi en essayant de résoudre le problème mais en vain .
Merci d'avance