IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

EDI, CMS, Outils, Scripts et API PHP Discussion :

[osCommerce] Undefined variable


Sujet :

EDI, CMS, Outils, Scripts et API PHP

  1. #1
    Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2014
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2014
    Messages : 2
    Points : 3
    Points
    3
    Par défaut [osCommerce] Undefined variable
    salut mes amis je suis le tuto proposer dans ce site ,,, pour un petit e-commerce, bon voila j'ai créé un les fonctionnalité supprimer un article du panier et supprimer un panier marche , mon problème c'est que lorsque j'ajoute un article en panier meme pour la 1er fois il m'affiche cette erreur Notice: Undefined variable: prixProduit in
    voila le résutat en image

    et aussi le code de la page fonction_panier
    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
     
     
    <?php
     
    	function creationPanier(){
    		try
    		 {
    			 $db = new PDO('mysql:host=localhost;dbname=site-e-commerce','root','');
    			 $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
    			 $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    		}
    		catch(Exception $e){
    			echo 'une erreur est survenu';
    			die();
    		}
     
     
    		if(!isset($_SESSION['panier'])){
     
    			$_SESSION['panier']=array();
    			$_SESSION['panier']['libelleProduit'] = array();
    			$_SESSION['panier']['qteProduit'] = array();
    			$_SESSION['panier']['prixProduit'] = array();
    			$_SESSION['panier']['verrou'] = false;
    			$select = $db->query("SELECT tva FROM products");
    			$data = $select->fetch(PDO::FETCH_OBJ);
    			$_SESSION['panier']['tva'] = $data->tva;
     
    		}
     
    		return true;
    	}
     
    	function ajouterArticle($libelleProduit, $qteProduit, $prixPoduit){
     
    		   if(creationPanier() && !isVerouille()){
     
    			   $positionProduit = array_search($libelleProduit, $_SESSION['panier']['libelleProduit']);
    			   if($positionProduit !== false){
     
    				   $_SESSION['panier']['qteProduit'][$positionProduit] += $qteProduit;
     
    			   }else{
     
    				   array_push( $_SESSION['panier']['libelleProduit'],$libelleProduit);
    				   array_push( $_SESSION['panier']['qteProduit'],$qteProduit);
    				   array_push( $_SESSION['panier']['prixProduit'],$prixProduit);
     
    				   }
     
    		   }else{
    			   echo 'Erreur, veillier contacter l\'administrateur';
    		   }
    	}
     
     
    	function modifierQteArticle($libelleProduit,$qteProduit){
     
    		if(creationPanier() && !isVerouille()){
    			if($qteProduit > 0){
     
    				$positionProduit = array_search($libelleProduit, $_SESSION['panier']['libelleProduit']);
    				if($positionPoduit !== false){
    					 $_SESSION['panier']['qteProduit'][$positionProduit] = $qteProduit;
     
    				}
     
    			   }else{
    				supprimerArticle($libelleProduit);
    			  }
     
     
    		}else{
    			echo 'Erreur, veulliez contacter un administrateur';
    		}
     
    	}
     
    	function supprimerArticle($libelleProduit){
     
    		if(creationPanier() && !isVerouille()){
    			$tmp = array();
    			$tmp['libelleProduit']=array();
    			$tmp['qteProduit']=array();
    			$tmp['prixProduit']=array();
    			$tmp['verrou']=$_SESSION['panier']['verrou'];
    			$tmp['tva']=$_SESSION['panier']['tva'];
     
    		for($i = 0; $i < count($_SESSION['panier']['libelleProduit']) ;$i++){
     
    			if($_SESSION['panier']['libelleProduit'][$i] !== $libelleProduit){
     
    				   array_push($tmp['libelleProduit'],$_SESSION['panier']['libelleProduit'][$i]);
    				   array_push($tmp['qteProduit'],$_SESSION['panier']['qteProduit'][$i]);
    				   array_push($tmp['prixProduit'],$_SESSION['panier']['prixProduit'][$i]);
     
    			}
     
    		}
    			$_SESSION['panier'] = $tmp;
    			unset($tmp);
     
    		}else{
    			echo 'Erreur, veulliez contacter un administrateur';
    	         }
    	}
    		function montantGlobal(){
    			$total=0;
    			for($i = 0; $i < count($_SESSION['panier']['libelleProduit']); $i++){
    				$total += $_SESSION['panier']['qteProduit'][$i]*$_SESSION['panier']['prixProduit'][$i];
    			}
    			return $total;
    		}
     
    		function montantGlobalTVA(){
    			$total=0;
    			for($i = 0; $i < count($_SESSION['panier']['libelleProduit']); $i++){
    				$total += $_SESSION['panier']['qteProduit'][$i]*$_SESSION['panier']['prixProduit'][$i];
    			}
    			return $total + $total*$_SESSION['panier']['tva']/100;
     
    		}
     
    		function supprimerPanier(){
     
                     unset($_SESSION['panier']);
     
    		}
     
     
    	   function isVerouille(){
    		   if(isset($_SESSION['panier'])&& $_SESSION['panier']['verrou']){
     
    			   return true;
    	        }else{
    		       return false;
    	       }
    		}
     
           function compterArticle(){
    		   if(isset($_SESSION['panier'])){
    			   return count($_SESSION['panier']['libelleProduit']);
    		   }else{
    			   return 0;
    		   }
    	}
     
     
     
    ?>
     
     
     
     
     
     
     
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="../style/bootstrap.css">
    <title>Document sans titre</title>
    </head>
     
    <body>
    </body>
    </html>

    et aussi le code pour ma page panier.php

    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
     
    <?php
     
    /* ini_set("display_errors",0);error_reporting(0); */
    ?> 
    <?php
     
     
     
    require_once('includes/hender.php');
    require_once('includes/sidebar.php');
    require_once('includes/functions_panier.php');
     
    $erreur = false;
     
    $action = (isset($_POST['action'])?$_POST['action']:(isset($_GET['action'])?$_GET['action']:NULL));
     
    if($action !== NULL){
    	if(!in_array($action, array('ajout','suppression','refresh')))
    		$erreur = true;
     
    		$l = (isset($_POST['l'])?$_POST['l']:(isset($_GET['l'])?$_GET['l']:NULL));
    		$q = (isset($_POST['q'])?$_POST['q']:(isset($_GET['q'])?$_GET['q']:NULL));
    		$p = (isset($_POST['p'])?$_POST['p']:(isset($_GET['p'])?$_GET['p']:NULL));
     
    	$l = preg_replace('#\v#','',$l); 	
     
    	$p = floatval($p);
     
    		if(is_array($q)){
    			$qteArticle = array();
    			$i = 0;
    		foreach($q as $contenu){
    			$qteArticle['$i++']= intval($contenu);
    		}
    	    }else{
    		     $q = intval($q);	
     
    	    }
     
     
    }
     
     
    if(!$erreur){
    	switch($action){
    		case "ajout":
    		   ajouterArticle($l,$q,$p);
     
    		break;
     
    		case "suppression":
    		     supprimerArticle($l);
     
    		break;
     
    		case "refresh":
    			for($i = 0; $i < count($qteArticle) ; $i++){
    				 modifierQteArticle($_SESSION['panier']['libelleProduit'][$i], round($qteArticle[$i]));
    			}
     
    		break;
     
    		default:
     
    		break; 
    	}
              }
     
    ?>
    <form method="post" action="">
        <table width="400">
             <tr>
                   <td colspan="4"><h3>Votre panier :</h3></td>
             </tr>
              <tr>
                   <td><h5>Libellé produit</h5></td>
                   <td><h5>Prix unitaires</h5></td>
                   <td><h5>Qantitées</h5></td>
                   <td><h5>TVA</h5></td>
                   <td><h5>Action</h5></td>
             </tr>
             <?php
     
    		 if(isset($_GET['deletepanier']) && $_GET['deletepanier']==true){
    			  supprimerPanier();
    		 }
     
     
    		    if(creationPanier()){
     
    			    $nbPorduit = count($_SESSION['panier']['libelleProduit']);
    			     if($nbPorduit <= 0){
     
    				      echo '<p style="font-size:30px; color:Red;">Oops, Panier Vide !</p>';
     
    				 }else{
     
    					 for($i = 0; $i < $nbPorduit; $i++){
    						 ?>
                             <tr>
     
    							 <td><br><?php echo $_SESSION['panier']['libelleProduit'][$i]; ?></td>
                                 <td><br><?php echo $_SESSION['panier']['prixProduit'][$i];?></td>
                                 <td><br><input name="q[]" value="<?php $_SESSION['panier']['qteProduit'][$i]?>" size="5"/></td>
                                 <td><br><?php echo $_SESSION['panier']['tva']."%";?></td>
                                 <td><br><a href="panier.php?action=suppression&amp;l=<?php echo rawurlencode($_SESSION['panier']['libelleProduit'][$i]);?>">Supprimer</a></td>
                              </tr> 
                              <?php } ?>
                              <tr>
                                   <td colspan="2">
                                    <h5>Total : <?php echo montantGlobal(); ?></h5><br> 
                                    <h5>Total avec TVA : <?php echo montantGlobalTVA(); ?></h5> 
                                   </td>
                              </tr>
                              <tr>
                                    <td colspan="4">
                                    <input type="submit" value="rafraichir"/>
                                    <input type="hidden" name="action" value="refresh"/>
                                    <a href="?deletepanier=true">Supprimer le panier</a>
                                    </td>
     
     
                              </tr>
     
     
     
     
     
                             <?php
     
     
    				 }
    			}
    		 ?>
     
        </table>
    </form>
    <?php
    require_once('includes/footer.php');
    ?>
     
     
     
     
     
     
     
     
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="style/bootstrap.css">
    <title>Document sans titre</title>
    </head>
     
    <body>
    </body>
    </html>
    merci pour votre aide

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    On n'a pas le droit d'avoir le message d'erreur en entier avec le numéro de la ligne ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2014
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2014
    Messages : 2
    Points : 3
    Points
    3
    Par défaut
    c bon j'ai réglé le problème merci pour votre attention
    j'ai tout simplement renommé prixProduit en PrixProduit et ça marché comme sur des roulettes

    et puis a la ligne 34 dans le code panier.php j'ai fait une erreur bete de '' $qteArticle['$i++']= intval($contenu); j'ai eu juste a enlevé ces deux '' et ça marche maintenant super bien pour la panier merci c gentilles

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Undefined variable: Idclic
    Par kratos59 dans le forum Langage
    Réponses: 7
    Dernier message: 11/05/2006, 16h50
  2. Notice: Undefined variable
    Par oranoutan dans le forum Langage
    Réponses: 19
    Dernier message: 21/12/2005, 22h28
  3. undefined variable
    Par ept35 dans le forum Langage
    Réponses: 3
    Dernier message: 30/11/2005, 15h48
  4. Notice: Undefined variable
    Par kayn dans le forum Langage
    Réponses: 2
    Dernier message: 03/10/2005, 20h44
  5. Réponses: 3
    Dernier message: 22/09/2005, 11h24

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo