Solved

Cannot use object of type stdClass as array

Posted on 2009-07-15
10
1,199 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
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.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

685 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