Solved

Cannot use object of type stdClass as array

Posted on 2009-07-15
10
1,163 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

707 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

11 Experts available now in Live!

Get 1:1 Help Now