ok, today i was working on a script and i got this error when i tried to display the information from an array.

now, i am not an expert on arrays, but ususally i can figure them out, but this error i've never seen.

at the end of the script there was this variabled: $response

so when i echo it, it didn't show anything,
echo $response;


then i thought, maybe its an array so i put this code:
echo "<pre>";
var_dump($response);
echo "</pre>";


it worked, i got these results on my browser: OUTPUT:
object(stdClass)#6 (9) {
["Timestamp"]=>
string(20) "2007-07-18T04:50:52Z"
["Ack"]=>
string(7) "Success"
["CorrelationID"]=>
string(13) "28c01821ba2c2"
["Version"]=>
string(8) "2.400000"
["Build"]=>
string(6) "1.0006"
["Amount"]=>
object(stdClass)#7 (2) {
["_"]=>
string(5) "40.00"
["currencyID"]=>
string(3) "USD"
}
["AVSCode"]=>
string(1) "X"
["CVV2Code"]=>
string(1) "M"
["TransactionID"]=>
string(17) "14E028078XJ827961UX"
}


ok, i didn't want to show this to my users, instead, i wanted to show only the TransactionID part so i put this code instead:
echo $response['TransactionID'][17];


that's when i got this error:


Fatal error: Cannot use object of type stdClass as array in C:windows-htdocs-cart.php on line 535


ok, so how do you fix this error,

i looked it up on google and found some post and forums where it say to upgrade my php or change the softwar or that i have a bad script. well, i finally figured out. it turns out that $response is actually an object. i have no idea what are objects in PHP but i came across an article about ojects and i found out that if you want to display it or show it with echo or print, you actually have to use the a different format. so in my example above, if i wanted to show the value TransactionID, this is how i would do it:

CODE
echo $response->TransactionID;


OUTPUT:
14E028078XJ827961UX


Perfect, just how i wanted.

well i hope this helps someone.

Thanks to webune.com for helping with this question. i have a dedicated server with them and they are very helpful with their support.

thanks webune.com