Call to a member function execute()
Résolu
BuddyLove_x52
Messages postés
131
Statut
Membre
-
hharchi9 Messages postés 693 Statut Membre -
hharchi9 Messages postés 693 Statut Membre -
Bonjour j'ai un problème avec une de mes fonction ligne 41 et j'arrive pas a la corrigé! J'ai passé l'après midi dessus , je viens faire appelle a vous car la j'en peut plus lol.
<meta charset="utf-8" />
<?php
function afficher_articles()
{
$articles = array();
try
{
// On se connecte à MySQL
$bdd = new PDO('mysql:host=localhost;dbname=blog;charset=utf8', 'root', '');
}
catch(Exception $e)
{
// En cas d'erreur, on affiche un message et on arrête tout
die('Erreur : '.$e->getMessage());
}
$req = $bdd->query('SELECT * FROM articles where ID_article='.$_GET['id']);
while($row = $req->fetch())
{
$articles[] = $row;
}
return $articles;
}
function inserer_commentaire($pseudo, $commentaire)
{
try
{
// On se connecte à MySQL
$bdd = new PDO('mysql:host=localhost;dbname=blog;charset=utf8', 'root', '');
}
catch(Exception $e)
{
// En cas d'erreur, on affiche un message et on arrête tout
die('Erreur : '.$e->getMessage());
}
// Si tout va bien, on peut continuer
$req = $bdd->query('INSERT INTO commentaires(pseudo, commentaires, date, id_article) VALUES(:pseudo, :commentaire, NOW(),:id');
$req->execute (array($_POST['pseudo'], $_POST['commentaire'], $_GET['id']));
}
?>
A voir également:
- Php call to a member function on array
- Qwerty to azerty - Guide
- Expert php pinterest - Télécharger - Langages
- Reboot to bootloader - Guide
- Video to video - Télécharger - Conversion & Codecs
- Crdownload to mp4 - Forum Téléchargement