Page 1 sur 1

ajouter une annonce en php pdo

Posté : 13 mars 2015, 23:03
par pacphil
bonjour voilà je vois pas l'erreur que je peut faire sur le script j'aurais besoin d'une petit coup de pouce svp?

Code : Tout sélectionner

<?PHP include'sources/config1.php'; // On envois la requète $compte = $connection->prepare('SELECT * FROM comptes WHERE pseudo=:pseudo'); $compte->execute(array(':pseudo'=> $_SESSION['xxxx'])); while($result = $compte->fetch(PDO::FETCH_OBJ)) if( $result) { $sexe_m = $result->sexe; $annonces=0; $pseudo= $_SESSION['xxxx']; $jours= $_POST["jours"]; $annonce=$_POST["annonce"]; echo $sexe; //Verification des differents champs echo ("<br>"); //Verification des champs if (!empty($annonce)) {} else{ echo' <script> $(document).ready(function() { $("#dialog").dialog({ modal: true, opacity: 0.1, minWidth: 400 , height: 170, position: [500,250], buttons: { "Ok": function() { window.location.href = ("http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/annonce.php?idm='.$_SESSION['idm'].'"); { $(this).dialog("close"); } } } }); }); </script>'; echo'<div align="center" id="dialog" title="Erreur">Vous avez oublier votre message!!!!</div>'; include'pieds.php'; return FALSE; } //Sauts de ligne $annonce = nl2br($annonce); if ($annonces==TRUE){ //insert les choix foreach ($_POST['Choix'] as $choix){ $add_annonce = array( ':pseudo'=> $pseudo, ':sexe'=> $sexe_m, ':choix'=> $choix, ':jours'=> $jours, ':annonce'=> $annonce); $values= join(', ',array_keys($add_annonce)); $req=$connection->prepare( 'INSERT INTO annonce ('.str_replace(':','',$values).') VALUES('.$values.')' ); $req->execute($add_annonce); } echo' <script> $(document).ready(function() { $("#dialog").dialog({ modal: true, minWidth: 400 , height: 150, position: [500,250], buttons: { "Ok": function() { window.location.href = ("http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/annonce.php?idm='.$_SESSION['idm'].'"); { $(this).dialog("close"); } } } }); }); </script>'; echo'<div align="center" id="dialog" title="Message">Votre annonce est ok.!!!!</div>'; include'pieds.php'; return FALSE; }else{ echo' <script> $(document).ready(function() { $("#dialog").dialog({ modal: true, minWidth: 400 , height: 150, position: [500,250], buttons: { "Ok": function() { window.location.href = ("http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/annonce.php?idm='.$_SESSION['idm'].'"); { $(this).dialog("close"); } } } }); }); </script>'; echo'<div align="center" id="dialog" title="Erreur">Veuillez recommencer!!!!</div>'; include'pieds.php'; return FALSE; } } $connection = null; ?>