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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
sowmya_ganesh
Forum Newbie
Posts: 8
Joined: Tue Nov 18, 2003 11:51 pm
Location: India

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

Post 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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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?
User avatar
sowmya_ganesh
Forum Newbie
Posts: 8
Joined: Tue Nov 18, 2003 11:51 pm
Location: India

YES

Post by sowmya_ganesh »

YES

i changed session_auto_start = 0

but still not working

what should i do
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Error message seems self-descriptive. You have to include() your class definition before session is started.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post 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
Post Reply