Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-28-2012, 09:20 AM   PM User | #16
rajdeep01
New Coder

 
Join Date: Dec 2012
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
rajdeep01 can only hope to improve
You can add conditional logic to vary the message returned, dependent upon the specific error code.

Here is an example of how to trap a 404 error and provide a custom message.

<?php if ($this->error->code == '404') { ?>
<div id="errorboxheader">Page not found</div>
<div id="errorboxbody"><p>Sorry! That page cannot be found.</p>
</div>
</div>
<?php } ?>
rajdeep01 is offline   Reply With Quote
Old 12-31-2012, 10:31 AM   PM User | #17
rajdeep01
New Coder

 
Join Date: Dec 2012
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
rajdeep01 can only hope to improve
If you want to see the error page in theme design and don't like redirecting to error page URL or duplicating HTML in the error page template, here is a way to apply your theme template to the error page.

First, put the following code in templates/<template-name>/error.php:

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

include dirname(__FILE__) . "/index.php";
?>
rajdeep01 is offline   Reply With Quote
Old 12-31-2012, 03:28 PM   PM User | #18
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,521
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by rajdeep01 View Post
You can add conditional logic to vary the message returned, dependent upon the specific error code.

Here is an example of how to trap a 404 error and provide a custom message.

<?php if ($this->error->code == '404') { ?>
<div id="errorboxheader">Page not found</div>
<div id="errorboxbody"><p>Sorry! That page cannot be found.</p>
</div>
</div>
<?php } ?>
Quote:
Originally Posted by rajdeep01 View Post
If you want to see the error page in theme design and don't like redirecting to error page URL or duplicating HTML in the error page template, here is a way to apply your theme template to the error page.

First, put the following code in templates/<template-name>/error.php:

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

include dirname(__FILE__) . "/index.php";
?>
What does either of these have to do with the ops error? - you're talking about a 404 (page not found) error in the first message and in the second I have no idea what you're trying to get at. Neither seem relevant to the actual problem.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 12-31-2012, 03:56 PM   PM User | #19
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Quote:
Originally Posted by vaporman87 View Post
Thank for that Tango. With your help I was able to get the site running. Though, I am finding some bugs. Here is one error I encountered and it's respective code:

Code:
Fatal error: Call to undefined method stdClass::update() in /home/vaporman/public_html/protected/controllers/SiteController.php on line 1231
PHP Code:
        Yii::app()->user->setFlash('msgError','Sorry, your reply could not be posted. Please try again.');
            }
            
        }
        else
        {
            
$forum->views+=1;
            
$forum->update();
        }
        
        
$cat ForumCategory::model()->findByPk($forum['category_id']); 
$forum->update(); is line 1231. Any thoughts, or need more info?

This error occurs when a user is logged in to my site and views a forum thread, then clicks the "RetroDaze" logo to return to the home page.
The site is located here: www.retro-daze.com
Can't help with the actual fix for this error since we don't know where or how its created, but the error itself is quite simple. $forum has been declared as a type stdclass ($forum = new stdclass()), but it is attempting to call a method for stdclass::update which will never exist (stdclass has no method update and PHP doesn't allow a way to trait into a stdclass object [at least I don't think it does]). So the issue is simply that $forum is not of the correct datatype. Why it isn't is unknown; for that you need to determine the creation sequence for the $forum variable and have it created as the correct type (maybe of a new Forum datatype?).

As for the above couple posts, love the randomness. I don't use any boxed CMS, but even I know that Joomla and Yii are different beasts.
Fou-Lu is offline   Reply With Quote
Old 12-31-2012, 04:10 PM   PM User | #20
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,521
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Quote:
Originally Posted by Fou-Lu View Post
As for the above couple posts, love the randomness.
He's done a couple of them in DoubleDees topic too
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:45 AM.


Advertisement
Log in to turn off these ads.