Voilà mon problème, j'ai un champs commentaire et je veux inscrire le commentaire de l'internaute en base je reçois systématiquement le message d'erreur suivant :
"Notice: Array to string conversion in C:\wamp\www\PHP\TP3\lokireservation_detail.php on line 66"
(la ligne 66 correspond à ma requête SQL :"$mysqli->query("REPLACE INTO avis (id_membre, id_salle, commentaire, note, date) VALUES ('$_SESSION[membre][id_membre]', '$salle_choisie[id_salle]', '$_POST[commentaire]', '$_POST[note]', now())");)
Voici mon code
<?php
$produit_demande=$mysqli->query("SELECT * FROM produit WHERE id_produit = '$_GET[id_produit]'");
$salle_demandee=$mysqli->query("SELECT * FROM salle INNER JOIN produit ON salle.id_salle = produit.id_salle");
$avis_demande=$mysqli->query("SELECT * FROM avis INNER JOIN produit ON avis.id_salle = produit.id_salle");
$produit_choisi = $produit_demande->fetch_assoc();
$avis_choisie = $avis_demande->fetch_assoc()
$salle_choisie = $salle_demandee->fetch_assoc();
var_dump($_SESSION);
var_dump($salle_choisie);
var_dump($_POST);
echo '<div class="blocpage">';
if(!InternauteEstConnecte()){
echo '<a href="connexion.php">connectez-vous pour laisser un commentaire</a>';
}else{
echo '<form method="post" action="">';
echo '<p><label for="Commentaire">Ajouter un commentaire</label></p>';
echo '<p><input type="text" id="commentaire" name="commentaire" style="width:200px; height:150px;"></p>';
echo '<p><label for="note">Notez nous sur une échelle de 1 à 10 : </label></p>';
echo '<p><input type="number" min="0" max="10" id="note" name="note" style="width:30px; height:15px;"> /10</p>';
echo '<p><input type="submit" name="validation_commentaire" value="soumettre"></p>';
echo '</form>';
if($_POST){
$mysqli->query("REPLACE INTO avis (id_membre, id_salle, commentaire, note, date) VALUES ('$_SESSION[membre][id_membre]', '$salle_choisie[id_salle]', '$_POST[commentaire]', '$_POST[note]', now())");
}
}
echo '</div>';
echo '<div class="blocpage">';
if($avis_choisie['note']){
echo 'Note : ' . $avis_choisie['note']. '/10';
}else{
echo 'Pas encore d\'avis sur cette salle';
}
echo '</div>';
?>
Voici ce que me donne les var_dump de $_SESSION; '$salle_choisie; $_POSTCode : Tout sélectionner
array (size=1)
'membre' =>
array (size=11)
'id_membre' => string '1' (length=1)
'pseudo' => string 'Laurent' (length=7)
'mdp' => string 'f817e4c76c91b9d3cc6d88cbf033651b' (length=32)
'nom' => string 'Laurent' (length=7)
'prenom' => string 'Laurent' (length=7)
'email' => string '[email protected]' (length=18)
'sexe' => string 'm' (length=1)
'ville' => string 'Ermont' (length=6)
'cp' => string '0' (length=1)
'adresse' => string '400 Rue Paul Bert' (length=17)
'statut' => string '0' (length=1)
array (size=16)
'id_salle' => string '1' (length=1)
'pays' => string 'France' (length=6)
'ville' => string 'Paris' (length=5)
'adress' => string '10 Rue des peuplier' (length=19)
'cp' => string '75' (length=2)
'titre' => string 'Saint Duval' (length=11)
'description' => string 'Jolie Salle' (length=11)
'photo' => string '/PHP/TP3/images/salle100x100.jpg' (length=32)
'capacite' => string '50' (length=2)
'categorie' => string 'reunion' (length=7)
'id_produit' => string '1' (length=1)
'date_arrivee' => string '2016-03-22 09:00:00' (length=19)
'date_depart' => string '2016-03-25 18:00:00' (length=19)
'id_promo' => null
'prix' => string '300' (length=3)
'etat' => string '0' (length=1)
array (size=0)
empty
D'avance merci
Laurent