Solved

Cannot use object of type stdClass as array

Posted on 2009-07-15
10
1,167 Views
Last Modified: 2012-05-07
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

0
Comment
Question by:R7AF
  • 5
  • 4
10 Comments
 
LVL 2

Accepted Solution

by:
dinu_sorin earned 500 total points
ID: 24857944
$advert_id =  $_SESSION['advert']->advert_id;//i guess $_SESSION['advert'] is an object.
0
 
LVL 14

Expert Comment

by:profya
ID: 24858074
The following will tell:
echo "<pre>";

print_r($_SESSION['advert']);

var_dump($_SESSION['advert']);

Open in new window

0
 
LVL 2

Expert Comment

by:dinu_sorin
ID: 24858293
well, since the $_SESSION can't normaly be an object, then the type of ['advert'] index is obvious
0
 
LVL 14

Expert Comment

by:profya
ID: 24858330
Try:
$advert_id =  $_SESSION['advert']->advert_id';
0
 
LVL 14

Expert Comment

by:profya
ID: 24858346
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

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 13

Author Closing Comment

by:R7AF
ID: 31603653
Thanks! I got it working.
0
 
LVL 2

Expert Comment

by:dinu_sorin
ID: 24858466
@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.
0
 
LVL 14

Expert Comment

by:profya
ID: 24858496
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.
0
 
LVL 2

Expert Comment

by:dinu_sorin
ID: 24858521
no worry :) i tought u did it on porpuse. Good luck at making your points ^_^.
0
 
LVL 14

Expert Comment

by:profya
ID: 24858540
Thanks dinu_sorin :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now