TomCavendish Posted February 21, 2007 Posted February 21, 2007 My host has upgraded from PHP 5.1 to PHP 5.2 so this problem will happen to lots of people and the error is with all my stores. When I try to add a new product or a new category I get the error message Catchable fatal error: Object of class upload could not be converted to string in /admin/includes/functions/html_output.php on line 248 Can anyone please help with this as it will help lots of others too. Please? TC.
TomCavendish Posted February 21, 2007 Author Posted February 21, 2007 This is the code in /admin/includes/functions/html_output.php // Output a form hidden field function tep_draw_hidden_field($name, $value = '') { $field = '<input type="hidden" name="' . $name . '" value="'; if ($value != '') { $field .= trim($value); } else { $field .= trim($GLOBALS[$name]); } $field .= '">'; return $field; } Line 248 is: $field .= trim($GLOBALS[$name]); Can someone please help me?
Guest Posted February 21, 2007 Posted February 21, 2007 This is the code in /admin/includes/functions/html_output.php // Output a form hidden field function tep_draw_hidden_field($name, $value = '') { $field = '<input type="hidden" name="' . $name . '" value="'; if ($value != '') { $field .= trim($value); } else { $field .= trim($GLOBALS[$name]); } $field .= '">'; return $field; } Line 248 is: $field .= trim($GLOBALS[$name]); Can someone please help me? This is the patch listed at php.net : http://www.php.net/UPDATE_5_2.txt
TomCavendish Posted February 21, 2007 Author Posted February 21, 2007 I've narrowed it down and the error only happens when you don't select an image when creating a 'new product' or 'new category'.
Guest Posted February 21, 2007 Posted February 21, 2007 I've narrowed it down and the error only happens when you don't select an image when creating a 'new product' or 'new category'. REALLY? That's weird. So you only see this error in the admin side ? Does it do an insert of the product anyway ? Or does it completly bail out and fail to insert ? Corrie
TomCavendish Posted February 21, 2007 Author Posted February 21, 2007 REALLY? That's weird. So you only see this error in the admin side ? Does it do an insert of the product anyway ? Or does it completly bail out and fail to insert ? Corrie Yep only in the admin. 1. You click 'add new product' (or new category) 2. Fill in the new product (or new category) details 3. Click on the 'preview' button 4. The preview page loads - except for the buttons at the bottom of the page, and instead of the buttons it shows the error message (so you can't add the new product or category). It only works when you give a new product or new category an image. It's fine to update products and categories, but not to add new ones that don't have an image. All worked fine until the host upgraded to PHP 5.2. It's beyond me, but hopefully this is enough info for someone who has the skills to fix it.
Guest Posted February 21, 2007 Posted February 21, 2007 Yep only in the admin. 1. You click 'add new product' (or new category) 2. Fill in the new product (or new category) details 3. Click on the 'preview' button 4. The preview page loads - except for the buttons at the bottom of the page, and instead of the buttons it shows the error message (so you can't add the new product or category). It only works when you give a new product or new category an image. It's fine to update products and categories, but not to add new ones that don't have an image. All worked fine until the host upgraded to PHP 5.2. It's beyond me, but hopefully this is enough info for someone who has the skills to fix it. Post your code from the case statement 'new_product_preview' from your admin/categories.php file. do a search for : case 'new_product_preview': and copy and paste these lines here (unless it already looks exactly like this, and if so, then say so) case 'new_product_preview': // copy image only if modified $products_image = new upload('products_image'); $products_image->set_destination(DIR_FS_CATALOG_IMAGES); if ($products_image->parse() && $products_image->save()) { $products_image_name = $products_image->filename; } else { $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : ''); } break; } } // check if the catalog image directory exists if (is_dir(DIR_FS_CATALOG_IMAGES)) { if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error'); } else { $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error'); } ?> Also - change the if loop above to this : if (is_dir(DIR_FS_CATALOG_IMAGES)) { $echome = "dir yes"; if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error'); } else { $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error'); $echome = "dir no"; } ?> Then find this line : <div id="spiffycalendar" class="text"></div> and change to this : <div id="spiffycalendar" class="text"></div><?php echo $echome ?> then find this line : tep_image_submit('button_back.gif', IMAGE_BACK, 'name="edit"') . ' '; and change to this : echo 'corrina_was_here'.tep_image_submit('button_back.gif', IMAGE_BACK, 'name="edit"') . ' '; Upload and try to add a new product. Does your output at the top say yes or no ? Does your output at the bottom say 'corrina_was_here' ? Corrie
TomCavendish Posted July 12, 2007 Author Posted July 12, 2007 Got it to work by commenting out the line: $field .= trim($GLOBALS[$name]); to // $field .= trim($GLOBALS[$name]);
Guest Posted October 5, 2010 Posted October 5, 2010 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] : ''); } }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.