Link to home
Start Free TrialLog in
Avatar of R7AF
R7AFFlag for Netherlands

asked on

Cannot use object of type stdClass as array

I get the following error when submitting a form that processes a payment by phone.

Fatal error: Cannot use object of type stdClass as array in /export/home/www.domain.com/htdocs/checkpayment.php on line 4

What is the problem here? Can this error message be about the includes?
<? include("includes/global.inc.php");
include("functions.php");
include("menu.php");
$advert_id =  $_SESSION['advert']['advert_id'];

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of dinu_sorin
dinu_sorin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The following will tell:
echo "<pre>";
print_r($_SESSION['advert']);
var_dump($_SESSION['advert']);

Open in new window

Avatar of dinu_sorin
dinu_sorin

well, since the $_SESSION can't normaly be an object, then the type of ['advert'] index is obvious
Try:
$advert_id =  $_SESSION['advert']->advert_id';
Sorry, there was a mistake. Make sure that advert_id is a member of your class.
$advert_id =  $_SESSION['advert']->advert_id;

Open in new window

Avatar of R7AF

ASKER

Thanks! I got it working.
@R7AF: i'm glad i could help. Happy coding!

@profya: try not to say same sugestion as other ppl did. You may stole their deserved points.
I read all posts dinu_sorin, I wonder how this happens. I do respect fellows, may be the slashes (advert_id;//i guess $_SESSION['advert'] is an object.) made me unfocused. I am in hurry, 4,000 points to be a master, may be this is the second reason for the rush. Sorry man. I'll focus much more in the future.
no worry :) i tought u did it on porpuse. Good luck at making your points ^_^.
Thanks dinu_sorin :)