Current location: Hot Scripts Forums » Programming Languages » PHP » Cannot use object of type stdClass as array


Cannot use object of type stdClass as array

Reply
  #1 (permalink)  
Old 11-05-08, 09:56 PM
tophat's Avatar
tophat tophat is offline
Newbie Coder
 
Join Date: Dec 2005
Location: Michigan
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Angry Cannot use object of type stdClass as array

I have a function which goes through an e-mail message and returns the attachments. The problem is, on certain e-mails, I am getting the error: "Cannot use object of type stdClass as array"

I tried researching this, but no one seems to offer a solution. I am not even really sure as to what the stdClass object is :/

Anyways, this is my code:

PHP Code:

function get_attachments($info$mbox$msg_id)

{
   
$struct imap_fetchstructure($mbox,$msg_id);
   
$contentParts count($struct->parts);

   if (
$contentParts >= 2)
   {
           for (
$i 2$i <= $contentParts$i++)
        {
               
$att[$i-2] = imap_bodystruct($mbox,$msg_id,$i);
           }
        
print_r($att);
           for (
$k 0$k sizeof($att); $k++)
        {
               if(
$att[$k]->parameters[0]->value == "us-ascii" || $att[$k]->parameters[0]->value == "US-ASCII"// HERE IS WHERE THE ERROR OCCURS!!!!
            
{
                   if (
$att[$k]->parameters[1]->value != "")
                {
                       
$selectBoxDisplay[$k] = $att[$k]->parameters[1]->value;
                   }
               } elseif (
$att[$k]->parameters[0]->value != "iso-8859-1" && $att[$k]->parameters[0]->value != "ISO-8859-1") {
                   
$selectBoxDisplay[$k] = $att[$k]->parameters[0]->value;
               }
           }
   }

   if (
sizeof($selectBoxDisplay) >= 1)
   {
        for (
$j=0;$j<sizeof($selectBoxDisplay);$j++)
        {
            echo 
"<a href=\"download.php?download=true&msg_id=$msg_id&file=$j&file_name=" base64_encode($selectBoxDisplay[$j]) . "\">Download " $selectBoxDisplay[$j] . "</a><br>";
        }
   } else {
        echo 
"No files attached.";
   }


Here is a sample of the array:

Array ( [0] => stdClass Object ( [type] => 2 [encoding] => 0 [ifsubtype] => 1 [subtype] => RFC822 [ifdescription] => 0 [ifid] => 0 [lines] => 131611 [bytes] => 10091972 [ifdisposition] => 0 [ifdparameters] => 0 [ifparameters] => 0 [parameters] => stdClass Object ( ) ) )

Does anyone know how to go about fixing this? Help would be greatly appreciated
__________________
tophatcomedy.com
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a browser RPG in javascript SolidSamurai JavaScript 26 10-20-08 03:27 PM
Object Or Array eddyvlad PHP 5 07-04-07 09:35 PM
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' Dr. Forensics PHP 3 07-15-06 03:54 PM
Return String values from a object saved in an array mr_wazzup Everything Java 1 04-15-05 09:11 AM
linking to iframe not working :( j0d JavaScript 5 01-19-04 08:14 PM


All times are GMT -5. The time now is 08:24 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.