Hi there, I just upgraded from php4 to php5 and now i'm getting the "Catchable fatal error: Object of class upload could not be converted to string in ..."

Here's my code indicated with the error. (any help is appreciated)

          
for ( $i=1 ; $i<13; $i++ ) { //error starts below
$products_subimage.$i = new upload('products_subimage'.$i); $products_subimage.$i->set_destination(DIR_FS_CATALOG_IMAGES); if ($products_subimage.$i->parse() && $products_subimage.$i->save()) { $products_subimage.$i_name = $products_subimage.$i->filename; } else { $products_subimage.$i_name = (isset($HTTP_POST_VARS['products_previous_subimage'.$i]) ? $HTTP_POST_VARS['products_previous_subimage'.$i] : ''); }
}

    Try changing with:

    $object = $products_subimage . $i;
    $object2 = $products_subimage. $i_name; // or did you actually want $object2 = $products_subimage . $i . "_name" ?
    
    //and then: $object->... $object2->...

    And give the whole error string (modify the "sensible" information, if you want). You don't want me to answer "Sure, the solution is: you make a concatenation with...".

      $products_subimage.$i = new upload('products_subimage'.$i);
      $products_subimage.$i->
      

      here is your problem you set products_subimage.$i as an object then try to convert it to a string inside the function.

        nevvermind;10965638 wrote:

        Try changing with:

        $object = $products_subimage . $i;
        $object2 = $products_subimage. $i_name; // or did you actually want $object2 = $products_subimage . $i . "_name" ?
        
        //and then: $object->... $object2->...

        And give the whole error string (modify the "sensible" information, if you want). You don't want me to answer "Sure, the solution is: you make a concatenation with...".

        nevvermind, your code saves the day (or week). thank you!

          jgetner;10965684 wrote:
          $products_subimage.$i = new upload('products_subimage'.$i);
          $products_subimage.$i->
          

          here is your problem you set products_subimage.$i as an object then try to convert it to a string inside the function.

          jgetner, thanks for your input. i kind of get what i did wrong but the weird thing is that it worked fine in php4.

            Write a Reply...