Page 1 of 1

Unknown(): The script tried to execute a method or.. URGENT

Posted: Tue Nov 18, 2003 11:51 pm
by sowmya_ganesh
Hai all

am new to PHP

i created a 2 classes
1 Items
1 ShoppingCart

user selects item and item object will have info of it. Am chencking wheather session 'cart' is null else creaing of shoppingcart object. using a function am adding the items to shopping cart am calling session_start() in all pages, i assigne session.auto_start to 0. i had written

if (!isset($_SESSION['Cart']))
{
echo "CART EMPTY <br>";
$_SESSION['Cart'] = new ShoppingCart();
}

when adding to session am using
$_SESSION['Cart']->addtocart($item);
but am getting a fatal error

Fatal error: Unknown(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition <b>shoppingcart</b> of the object you are trying to operate on was loaded _before_ the session was started in C:\Program Files\Apache Group\Apache2\htdocs\mybenz\shoppingcart.php on line 29


please tell me why am getting this errror

its urgent pls help me

Posted: Wed Nov 19, 2003 12:02 am
by infolock
have you checked and made sure that session_auto_start is disabled in php.ini ? To do this, change 1 to 0 and it will disable it.


hope that helps, otherwise is any way we can see more of the code?

YES

Posted: Wed Nov 19, 2003 12:32 am
by sowmya_ganesh
YES

i changed session_auto_start = 0

but still not working

what should i do

Posted: Wed Nov 19, 2003 12:39 am
by infolock
first of all, did you restart your web server ?

otherwise, someone with a little more info on this may be able to help you out.

Posted: Wed Nov 19, 2003 6:40 am
by Weirdan
Error message seems self-descriptive. You have to include() your class definition before session is started.

Posted: Wed Nov 19, 2003 10:09 am
by infolock

Code: Select all

YES 

i changed session_auto_start = 0 

but still not working 

what should i do
The thing is, she isn't getting that error now because she did the change in the php.ini file and it corrected the first problem. Her current problem is dealing with an array. I've talked with her in private chat and suggested posting the question and the code here on this thread, but she doesn't seem to want to heh. :P