dgowrie Posted November 30, 2012 Share Posted November 30, 2012 (edited) Hi all, I have a website that is now showing an error message I have no clue about. I think I know the cause to be changing my web hosting php version from 5.2 to 5.4. I have now changed this back but i'm still getting the error: Warning: Creating default object from empty value in /homepages/32/d291630191/htdocs/RCON/modules/mod_fpss/mod_fpss.php on line 143 I have attached the file it refers to, the website to see the error is www.renovoconstruction.co.uk If anyone could help it would be greatly appreciated Many Thanks, David <snip removed attached file> Edited December 4, 2012 by PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/271412-warning-creating-default-object-from-empty-value/ Share on other sites More sharing options...
MDCode Posted November 30, 2012 Share Posted November 30, 2012 It's doubtful that anyone will download a file attachment. Please post the code on here instead. Quote Link to comment https://forums.phpfreaks.com/topic/271412-warning-creating-default-object-from-empty-value/#findComment-1396483 Share on other sites More sharing options...
silkfire Posted November 30, 2012 Share Posted November 30, 2012 You get this error because you're trying to assign properties to an object that hasn't been declared previously. Your best way to solve it is to create an empty object (stdClass) and then put as the value of its respective key. $slide_object = new stdClass; // Slide name if ($row->itemlink && $row->title) $slide_object->name = $row->title; //$row->name elseif ($row->menulink && $menuItem) $slide_object->name = $menuItem->name; //$row->name else $slide_object->name = $row->name; if (!$showName) $slide_object->name = ''; $output[$key] = $slide_object; Quote Link to comment https://forums.phpfreaks.com/topic/271412-warning-creating-default-object-from-empty-value/#findComment-1396488 Share on other sites More sharing options...
dgowrie Posted November 30, 2012 Author Share Posted November 30, 2012 You get this error because you're trying to assign properties to an object that hasn't been declared previously. Your best way to solve it is to create an empty object (stdClass) and then put as the value of its respective key. $slide_object = new stdClass; // Slide name if ($row->itemlink && $row->title) $slide_object->name = $row->title; //$row->name elseif ($row->menulink && $menuItem) $slide_object->name = $menuItem->name; //$row->name else $slide_object->name = $row->name; if (!$showName) $slide_object->name = ''; $output[$key] = $slide_object; Sorry Silk but I have no idea what you have suggested or how I do it. Is the code you have posted what I need to add to the php file? If so where does it need to go? Many Thanks David Quote Link to comment https://forums.phpfreaks.com/topic/271412-warning-creating-default-object-from-empty-value/#findComment-1396492 Share on other sites More sharing options...
dgowrie Posted November 30, 2012 Author Share Posted November 30, 2012 Sorry for the double post but I've copied and pasted the code silk gave me and I've now got the same error but on a new line in the file. Line 159 I just don't know enough about PHP to fix this if it's a multiple thing so any additional help would be great. Many Thanks David Quote Link to comment https://forums.phpfreaks.com/topic/271412-warning-creating-default-object-from-empty-value/#findComment-1396545 Share on other sites More sharing options...
trq Posted November 30, 2012 Share Posted November 30, 2012 Again, post some relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/271412-warning-creating-default-object-from-empty-value/#findComment-1396546 Share on other sites More sharing options...
dgowrie Posted November 30, 2012 Author Share Posted November 30, 2012 (edited) <snip removed copyrighted code> Edited December 4, 2012 by PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/271412-warning-creating-default-object-from-empty-value/#findComment-1396561 Share on other sites More sharing options...
dgowrie Posted December 4, 2012 Author Share Posted December 4, 2012 Can anyone help on this? The first error was on line 143 and since I copied and pasted the code silkfire gave it now says error on line 159. I have no idea whether this is the same error and its moved from the code I put in or a new error? Many Thanks David Quote Link to comment https://forums.phpfreaks.com/topic/271412-warning-creating-default-object-from-empty-value/#findComment-1397455 Share on other sites More sharing options...
MDCode Posted December 4, 2012 Share Posted December 4, 2012 As much as I'd love to go counting lines? Which lines are 143 and 159? Quote Link to comment https://forums.phpfreaks.com/topic/271412-warning-creating-default-object-from-empty-value/#findComment-1397457 Share on other sites More sharing options...
dgowrie Posted December 4, 2012 Author Share Posted December 4, 2012 Haha, sorry social. Lines 142 to 160 are below: // Compare display options between component and module $showName = ($fpssSlideTitle=='') ? $row->showtitle : $fpssSlideTitle; $showSectionTitle = ($fpssSlideSec=='') ? $row->showseccat : $fpssSlideSec; $showCategoryTitle = ($fpssSlideCat=='') ? $row->showseccat : $fpssSlideCat; $showText = ($fpssSlideText=='') ? $row->showcustomtext : $fpssSlideText; $showTagline = ($fpssSlideTagline=='') ? $row->showplaintext : $fpssSlideTagline; $showReadMore = ($fpssSlideReadMore=='') ? $row->showreadmore : $fpssSlideReadMore; // Get menu data if($row->menulink) $menuItem = $menu->getItem($row->menulink); // Slide name if($row->itemlink && $row->title){ $output[$key]->name = $row->title; //$row->name } elseif($row->menulink && $menuItem){ $output[$key]->name = $menuItem->name; //$row->name } else { $output[$key]->name = $row->name; } Quote Link to comment https://forums.phpfreaks.com/topic/271412-warning-creating-default-object-from-empty-value/#findComment-1397463 Share on other sites More sharing options...
PFMaBiSmAd Posted December 4, 2012 Share Posted December 4, 2012 You have a third party script that is either - A) Missing some code (or it's not being seen as being code) that would have defined the missing objects, which means that you won't get it to actually work just by 'fixing' each of these current errors, because there is more missing than is what is causing these current errors, or B) It is a poorly written script that always produced these errors, but they were being hidden by php's error_reporting/display_errors settings. In fact, this is a purchased copyrighted script that you cannot post here (I have edited your posts to remove the complete code). You should contact the author for support. Also, moving this thread to the third party script forum section. Quote Link to comment https://forums.phpfreaks.com/topic/271412-warning-creating-default-object-from-empty-value/#findComment-1397471 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.