bonjour à tous, voici mon petit problème : je créé un site de e-commerce en local pour m'entrainer et j'ai des soucis avec mon panier :
voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
if(isset($_GET['produit']))//contient l'id du produit à ajouter au panier
{
	$req=mysql_query("select * from produits where id_produit='".$_GET['produit']."'");
	$query=mysql_fetch_array($req);
	if(!isset($_SESSION['panier']))
	{
		//crée le tableau session pr faire le panier
		$_SESSION['panier'] = array();
		$_SESSION['panier']['id_produit'] = array();
		$_SESSION['panier']['nom_produit'] = array();
		$_SESSION['panier']['prix_produit'] = array(); 
		$_SESSION['panier']['qte'] = array();
	}
	else 
	{
		$selec=mysql_query("select * from produits where id_produit='".$_GET['produit']."';");
		$select=mysql_fetch_array($selec);
                //cette boucle suivi du if devrai me servir à eviter les doublons en augmentant la quantité
		$i=0;
		foreach($_SESSION['panier']['nom_produit'] as $valeur)
		{
			$i++;
		}
		if($i>0)
			$_SESSION['panier']['qte']=$_SESSION['panier']['qte']$i;
		array_push($_SESSION['panier']['id_produit'],$select['id_produit']);
		array_push($_SESSION['panier']['nom_produit'],$select['nom_produit']);
		array_push($_SESSION['panier']['qte'],$qte); 
		array_push($_SESSION['panier']['prix_produit'],$select['prix_produit']); 
 
 
		echo'Article ajouté au panier : Nom : '.$select['nom_produit'].' Quantité : '.$qte.' Prix unitaire :'.$select['prix_produit'].'€ Prix total : '.($_SESSION['panier']['qte']*$i).'€ <br/>Cliquer <a href="./boutique.php">ici</a> pour revenir aux choix des produits.<br/>Cliquer <a href="./panier.php">ici</a> pour voir votre panier.';
	}
}
évidemment celà ne marche pas :S
la variable $qte n'est pas encore présente donc pour mes test j'ai défini la variable $qte à 1 mais ça ne fonctionne toujours pas, voilà l'erreur reçue que je ne parviens pas à identifier :

( ! ) Warning: array_push() expects parameter 1 to be array, integer given in C:\wamp\www\momo\new\panier.php on line 33
Call Stack
# Time Memory Function Location
1 0.0006 396296 {main}( ) ..\panier.php:0
2 0.0055 413384 array_push ( ) ..\panier.php:33

Sinon mon panier marche en dehors de cet aspect de doublons à suprimer en augmentant la quantité.
Merci de m'avoir lu