jmosher Posted September 24, 2006 Share Posted September 24, 2006 I'm hoping someone might be able to help me out with this issue. I converted to PHP5 from PHP4 and found there are new stricter methods to handle calls and queries.When I try to logon to my system to access my database I receive the following error:Fatal error: Call to undefined method stdClass::setPageContent() in /usr/share/calltracker/includes/functions.php on line 402Here is the code specific to that section in functions.php:400 # First set the page content array entry401402 $result->setPageContent();403404 # Get the page navigation function405406 $result->parameters["SMALL_NAV"] = admin_page_navigation();407 $result->parameters["NAV_TREE"] = admin_page_navigation("tree");408 $result->parameters["USER_NAVBAR"] = user_page_navigation();409 $result->parameters["VERSION"] = EP_VERSION;410 $result->parameters["SCRIPT_NAME"] = EP_SCRIPT_NAME;411 $result->parameters["COPYRIGHT"] = COPYRIGHT;412 $result->parameters["NUMQUERIES"] = count($db->queries);413414 # Set the template to the configured value415416 if($result->template == "") { $result->template = $CONF['template']; }417418 if($result->no_cache == 1)419 {420 $result->html = $GLOBALS['reg'];421 }422 else423 {424 # Import the template code425426 $result->html = implode(file($result->template),"");427 }428429 # Replace every tag in the template430 # with its entry in the parameters431 # array432433 foreach($result->parameters as $key => $value)434 {435436 $result->tag = '{' . "$key" . '}';437438 if($key != "PAGE_CONTENT")439 {440 $result->html = str_replace($result->tag,$value,$result->html);441 }442443 }444445 $result->html = str_replace("{PAGE_CONTENT}", $result->parameters["PAGE_CONTENT"], $result->html);446447 # Output the created HTML code448449 echo($result->html);450451 }452453 # This function will set a value in the parameters454 # array455456 function setParameter($name,$value) {457458 $result->parameters[$name] = $value;459460 }461462 # This concludes the template object463464 }No problems are experienced when using PHP4.3.xNote**: The variable $result has replaced the accepted variable function $this as $this has been discontinued in version 5 and support is no longer offered.Thanks for any help offered. Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/ Share on other sites More sharing options...
Barand Posted September 24, 2006 Share Posted September 24, 2006 [quote author=jmosher link=topic=109235.msg440152#msg440152 date=1159057811]... as $this has been discontinued in version 5 and support is no longer offered.[/quote]And there's me using $this with version 5 classes with no problems. They obviously forgot to to include me in the circulation list when that memo went out. Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-97458 Share on other sites More sharing options...
wildteen88 Posted September 24, 2006 Share Posted September 24, 2006 [quote]Note**: The variable $result has replaced the accepted variable function $this as $this has been discontinued in version 5 and support is no longer offered.[/quote]Huh! I agree with Barand here. $this has not been discontinued from PHP5. If it has the documentation would reflect this and my OO programmed scripts will fail work. Where did you get that from? Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-97647 Share on other sites More sharing options...
jmosher Posted September 24, 2006 Author Share Posted September 24, 2006 Hi Guys,What I did was roll back as per your notion support for $this has not been dropped and this is the original error received:Fatal error: Cannot re-assign $this in /usr/share/calltracker/includes/functions.php on line 964Here is the code snippet for the function having a problem.946 //--------------------------------------------------------+ 947 // Admin table heading output | 948 //--------------------------------------------------------+ 949 950 function admin_table_heading( $title="" ) { 951 952 global $template, $CONF; 953 954 //-------------------------------- 955 // If this has not yet been loaded, 956 // load it and cache it. 957 958 if(!isset($GLOBALS['table_header_html'])) 959 #{ 960 #$lines = implode( file("../includes/admin_skins/".$CONF['admin_template']."/table-heading.inc"), ""); 961 #$GLOBALS['table_header_html'] = $lines; 962 #} 963 964 $this = str_replace("{TITLE}", $title, $GLOBALS['table_header_html']); 965 966 output( $this ); 967 968 unset($this); 969 970 output( "<table width=100% cellpadding=0 cellspacing=0 style=\"border-bottom: 1px solid #1B95CE\"> 971 <tr><td width=20><img src=../images/general/table-topleft.jpg></td> 972 <td background=../images/general/table-toptile.jpg height=21><table width=100% 973 cellpadding=0 cellspacing=0><tr><td><font color=white><b> " . $title . "</b></font></td></tr></table></td><td width=20><img src=../im ages/general/table-topright.jpg></td> 974 </tr>"); 975 976 }The original error I posted was produced following these changes -Updating $this to $result as per this php page indicating that the $this variable was an undocumented feature that was never to be supported and officially dropped in version 5:http://bugs.php.net/bug.php?id=27659&edit=1Setting these functions to array functions, which are now required based on the way php5 parses the information.585c585< mysql_close($this->connection);---> @mysql_close($result->connection);591c591< return mysql_insert_id();---> return @mysql_insert_id();602c602< return mysql_error();---> return @mysql_error();So now I'm at the original start point with no applied changes and I'm hoping you could help.Thanks--Jerry Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-97824 Share on other sites More sharing options...
Barand Posted September 24, 2006 Share Posted September 24, 2006 As $this refers to the current object, you can hardly be surprised when it objects to being reassigned as a string variable in964 $this = str_replace("{TITLE}", $title, $GLOBALS['table_header_html']);Even trying to assign another object to $this seems to me to be the programming equivalent of sitting on a branch and sawing it off at the trunk. Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-97832 Share on other sites More sharing options...
jmosher Posted September 25, 2006 Author Share Posted September 25, 2006 How would you suggest it be corrected? Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-97846 Share on other sites More sharing options...
neylitalo Posted September 25, 2006 Share Posted September 25, 2006 [quote author=Barand link=topic=109235.msg440555#msg440555 date=1159139625]... seems to me to be the programming equivalent of sitting on a branch and sawing it off at the trunk.[/quote]Several cheers for great analogies. Hipy papy bthuthdth thuthda bthuthdy!And to fix your problem:Lines 964 to 968[code]$this = str_replace("{TITLE}", $title, $GLOBALS['table_header_html']);output( $this );unset($this);[/code]Replace $this with anything. [code]$result = str_replace("{TITLE}", $title, $GLOBALS['table_header_html']);output($result);unset($result);[/code]Replace $result with your favorite variable. Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-97862 Share on other sites More sharing options...
jmosher Posted September 25, 2006 Author Share Posted September 25, 2006 I'll give that a shot. Do I still need to set the @ function in front of the variables I mentioned previously. Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-97866 Share on other sites More sharing options...
trq Posted September 25, 2006 Share Posted September 25, 2006 The error supreser should IMO be avoided where possible. However, if you have your own error handling in place, sometimes it can come in handy. Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-97904 Share on other sites More sharing options...
jmosher Posted September 25, 2006 Author Share Posted September 25, 2006 BTW it worked well.Would you explain a bit more so I can be humbled by your ever growing GOD complex. Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-97920 Share on other sites More sharing options...
trq Posted September 25, 2006 Share Posted September 25, 2006 What are you insinuating by such a comment? I thought I put my last response in pretty clear straight forward terms.Surely.. if you've written the code you've posted your aware of what the error supersor (@) is and does. And, one would also assume that if your using classes you should have the ability to create your own error handling / trapping. If this isn't your code youve posted, then Im sorry, but you gave the impression you knew what you where talking about. Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-97927 Share on other sites More sharing options...
jmosher Posted September 25, 2006 Author Share Posted September 25, 2006 You have a great day.I knew someone had a GOD complex.--------------- Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-98041 Share on other sites More sharing options...
trq Posted September 25, 2006 Share Posted September 25, 2006 Have you got a question or what? Quote Link to comment https://forums.phpfreaks.com/topic/21820-fatal-error-experienced-after-converting-to-php5-from-php4/#findComment-98046 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.