Ratiche Posted May 28, 2008 Share Posted May 28, 2008 Bonjour voila lorsque je rajoute un article dans mon panier il me le rajoute mais ne me met pas tout ce que je lui demande. Voici l'erreur: Notice: Undefined index: an in C:\Program Files\EasyPHP 2.0b1\www\panieroriginal.php on line 18 et voici mon code: le panier: function creationPanier() { $ret=false; if (isset( $_SESSION['panier'])) { $ret = true; } else { $_SESSION['panier']=array(); $_SESSION['panier']['Nom_auteur'] = array(); $_SESSION['panier']['Titre'] = array(); $_SESSION['panier']['Prix_vente_euro'] = array(); $_SESSION['panier']['Annee'] = array(); $ret=true; } return $ret; } Et le lien pour ajouter l'article au panier: <a href=\"panieroriginal.php?action=ajout&au=".$req2['Nom_auteur']."&t=".$req2['Titre']."&p=".$req2['Prix_vente_euro'].";an=".$req2['Annee']."&\" onclick='window.open(this.href, '', 'toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=yes, copyhistory=no, width=600, height=350'); return false;'>Ajouter au panier</a> la fonction permettant d'ajouterun article: function ajouterArticle($Nom_auteur,$Titre,$Prix_vente_euro,$Annee) { if (creationPanier()) { array_push( $_SESSION['panier']['Nom_auteur'],$Nom_auteur); array_push( $_SESSION['panier']['Titre'],$Titre); array_push( $_SESSION['panier']['Prix_vente_euro'],$Prix_vente_euro); array_push( $_SESSION['panier']['Annee'],$Annee); } else { echo "Un problème est survenu veuillez contacter l'administrateur du site."; } } et j'utilise ca pour ajouter, supprimer ou vider le panier: if (isset($_GET['action'])) { if(in_array( $_GET['action'],array('ajout', 'suppression', 'viderPanier', 'supprimerBD'))) { $action = $_GET['action']; } switch($action) { Case "ajout": $au=preg_replace('#\v#', '',$_GET['au']); $t=preg_replace('#\v#', '',$_GET['t']); $p=floatval($_GET['p']); $an=intval($_GET['an']); ajouterArticle($au,$t,$p,$an); break; Case "suppression": $t=preg_replace('#\v#', '',$_GET['t']); supprimerArticle($t); break; Case "viderPanier": viderPanier(); break; Default: break; } } Link to comment Share on other sites More sharing options...
Bab00n Posted May 28, 2008 Share Posted May 28, 2008 Tu peut indiquer dans ton code la ligne mis en question dans l'erreur ? parce qu'on a pas les nom de fichier et les ligne alors on sais pas trop Sinon déja, ta fonction "creationPanier()", si je me trompe pas, elle renvoie toujours "true" non ? donc le if (creationPanier()) sera toujours vrai ... Link to comment Share on other sites More sharing options...
Ratiche Posted May 28, 2008 Author Share Posted May 28, 2008 La ligne mis en question est celle-ci: (elle vient du dernier fichier celui ou je rajoute, supprime des articles ou vide le panier) $an=intval($_GET['an']); Et oui en effet normalement elle retournera tjs vrai. Et mon if sera tjs vrai oui. Link to comment Share on other sites More sharing options...
Ratiche Posted May 29, 2008 Author Share Posted May 29, 2008 c bon j'ai résolu le problème Link to comment Share on other sites More sharing options...
Mephisto Posted May 30, 2008 Share Posted May 30, 2008 (eventuellement, pense a metre la solution, et a rajouter au titre du topic 'resolu') Link to comment Share on other sites More sharing options...
Amour Posted May 30, 2008 Share Posted May 30, 2008 La solution est la suivante (je suppose) : $_GET['an'] est utilisé sans vérifier qu'il existe ou pas (avec isset()) donc le script est pas content et dit que l'index existe pas Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.