Bonjour, me voici confronté à un problème que je ne maitrise pas du tout.

J'ai une classe CPanier. A l'intérieur, j'utilise la variable $panier comme tableau à 2 dimensions.

$panier ['reference'] // Référence de l'article
|
|____['prix']
|____['quantite']
|.... etc
dans ce esprit là. Bien sur, j'ai maintenant compris qu'il y avait de meilleures façons de faire, mais l'échéance approche et je n'ai plus le temps de tout refaire car il fonctionnait très bien en local, mais lors de sa mise en ligne sur le serveur plus rien ne fonctionnait : il affiche l'erreur suivante :

Fatal error: Cannot use object of type CPanier as array in /homez.39/xxxxx/www/xxxxx/php/CPanier.php on line 69
Voilà, je ne sais plus quoi faire voici ma classe au complet :

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
<?php
 
class CPanier {
 
// Données membres
 
  public $panier = array(array());
 
// Constructeur 
 
 function __construct() {
 
	if (!isset($_SESSION['panier'])) $_SESSION['panier'] = array();
 
	$this->panier =& $_SESSION['panier'];
 
 }
 
// Methodes
 
 public function ajouteArticle($ref,$qte=1){
 
	$infos = $this->voirInfos($ref);
 
	@$this->panier[$ref]['quantite'] += $qte;
	@$this->panier[$ref]['reference'] = $ref;
 
 
	@$this->panier[$ref]['photo'] 	= $infos['pic'];
	@$this->panier[$ref]['titre'] 	= $infos['nom'];
	@$this->panier[$ref]['prix'] 	= $infos['prix'];
	@$this->panier[$ref]['poids'] 	= $infos['poids'];
	@$this->panier[$ref]['cat']		= $infos['cat'];
 
	if ($qte <= 0) unset ($this->panier[$ref]);
 
}
 
 public function supprimeArticle($ref='',$qte=1){
 
	@$this->panier[$ref]['quantite'] -= $qte;
 
	if ($this->panier[$ref]['quantite'] <= 0) unset ($this->panier[$ref]);
 
}
 
 public function changeQuantite($ref='',$toSet=''){
 
	@$this->panier[$ref]['quantite'] = $toSet ;
 
	if ($this->panier[$ref]['quantite'] <= 0) unset ($this->panier[$ref]);
 
 }
 
 public function voirQuantite($ref=''){
 
	if ($ref) {
		return $this->panier[$ref]['quantite'];
	}
 
	else {
 
		$total = 0;
 
		foreach($this->panier as $ref => $data) {	
 
			$total += $data['quantite'];
 
		}
 
		return $total;
 
	}
 
 }
 
 public function voirInfos($ref) { // Affiche le prix d'un article, sinon le total (sans ref)
 
	if (!is_null($ref)) $ref = 'WHERE `id`='. $ref;
 
		$select = 'SELECT `id`,`prix`,`poids`,`photo`,`titre`,`categorie` FROM '. DB_PREFIX .'catalogue '. $ref;
		$query	= mysql_query($select);
 
		$row 	= mysql_fetch_row($query);
 
		return array(
			'prix' 	=> $row[1],
			'poids'	=> $row[2],
			'ref'	=> $row[0],
			'pic'	=> $row[3],
			'nom'	=> $row[4],
			'cat'	=> $row[5]
			);
 }
 
 public function voirPanier(){
 
	$list = array();
	$i = 0;
 
	foreach($this->panier as $ref => $data) {
 
		$list['ref'][$i] = $ref;
		$list['pic'][$i] = $data['photo'];
		$list['nom'][$i] = $data['titre'];
		$list['qte'][$i] = $data['quantite'];
		$list['prx'][$i] = $data['prix'];
		$list['pds'][$i] = $data['poids'];
		$list['cat'][$i] = $data['cat'];
		$i++;
	}
 
	return $list;
 }
 }
 ?>
Autre détails, j'ai fait un print_r de $this->tableau c'est bien un tableau à deux dimensions. J'ai bien démarré ma session après et seulement après avoir fait un require_once() de ma classe.

Tout fonctionns bien en local sur un php 2.5.0 et mon serveur qui ne l'accepte pas c'est php 2.5.6

Merci de m'aider à trouver la solution la plus rapide ! Cordialement.