|
Posted by Jorge A on 10/22/05 14:14
Hi! I'm creating a kind of shipping cart and it's very strange, it works
perfect from the 2nd time I view the script, but the 1st time I view
it I obtain an error message.
new.php
------------------------
include "class.cart.php";
session_register('carro');
if(!isset($_SESSION['carro']->num_programs)){
$carro = new cart();
}
$_SESSION['carro']->add($_GET['date'],$_GET['start'],$_GET['stop'],$_GET['chan'],$_GET['title']);
$_SESSION['carro']->show();
------------------------
I obtain this error message the first time I use it:
"Fatal error: Call to a member function add() on a non-object in
C:\...\new.php on line 41"
Nevertheless, the 2nd, 3rd... time I use it, it works OK. Maybe the cart
isn't initialized well:
class.cart.php
-------------------------
class cart {
var $num_programs;
var $array_progvalido;
var $array_titles;
var $array_dates;
var $array_start;
var $array_stop;
var $array_channels;
function cart() {
$this->num_programs=0;
$this->array_progvalido[]=0;
$this->array_titles[]=0;
$this->array_dates[]=0;
$this->array_start[]=0;
$this->array_stop[]=0;
$this->array_channels[]=0;
}
function add($date,$start,$stop,$channel,$title){
$this->array_progvalido[$this->num_programs]=1;
$this->array_titles[$this->num_programs]=$title;
$this->array_dates[$this->num_programs]=$date;
$this->array_start[$this->num_programs]=$start;
$this->array_stop[$this->num_programs]=$stop;
$this->array_channels[$this->num_programs]=$channel;
$this->num_programs++;
}
------------------------------
Please help, I'm desperated!
Thanks in advance
Navigation:
[Reply to this message]
|