Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Fatal error: Using $this when not in object context
Old 01-19-2010, 09:07 PM Fatal error: Using $this when not in object context
Junior Talker

Posts: 2
Trades: 0
Dear All,

When i try to run the following code, it give me the fatal error as the titile. Can anyone know what's wrong with the code and how to correct it?

Working environment: php5 ,fedora 11.

Thanks for your help,

Best Regards,
Addison

PHP Code:
<?php  
$data
['hide_menu'] = true
$data['scripts'] = array('prototype''scriptaculous''validation''control.modal''scripts'); 
$this->load->view('include/header'$data); 
?> 
    <h2>Login</h2> 
 
    <div id="login_status" style="display:none">     
    </div> 
 
    <div class="" id="badbrowser"> 
     <b class="ajax_error_round"><b class="ajax_error_round1"><b></b></b><b class="ajax_error_round2"><b></b></b> 
     <b class="ajax_error_round3"></b><b class="ajax_error_round4"></b><b class="ajax_error_round5"></b></b><div class="ajax_error_roundfg"> 
     <?=$this->lang->line('login_bad_browser')?> 
     </div><b class="ajax_error_round"><b class="ajax_error_round5"></b><b class="ajax_error_round4"></b><b class="ajax_error_round3"></b> 
     <b class="ajax_error_round2"><b></b></b><b class="ajax_error_round1"><b></b></b></b> 
    </div> 
     
    <div id="leightbox" style="display: none"> 
     <h3><?=$this->lang->line('login_wait')?></h3> 
     <?=$this->lang->line('login_login_checking')?><br /><br /> 
     <img src="<?=base_url()?>public/images/indicator_bar.gif" alt="Please Wait..." /> 
    </div> 
     
    <form id="login_form" action="<?=site_url()?>ajaxerror" method="post" style="display: none;" onsubmit="return false;"> 
     <fieldset> 
     <legend>WebSAM Login</legend> 
     <table> 
      <tbody> 
      <tr> 
       <td><label for="user_id"><?=$this->lang->line('login_card_number')?>:</label></td> 
       <td><input name="user_id" id="user_id" type="text" class="required" title="<?=$this->lang->line('login_card_message')?>" /></td> 
      </tr> 
<?php if (sizeof($enttable) != 1): ?>       
      <tr> 
       <td><label for="user_passwd"><?=$this->lang->line('login_password')?>:</label></td> 
       <td><input name="user_passwd" id="user_passwd" type="password" class="required" title="<?=$this->lang->line('login_password_message')?>" /></td> 
      </tr> 
<?php endif; ?> 
      <tr> 
          <td><label for="lang"><?=$this->lang->line('login_language')?>:</label></td> 
          <td><select id="lang" name="lang"> 
       <option id="en" value="en" selected="selected">English</option> 
              </select> 
              <a class="ajax_link" onmousedown="reload_page()"><img src="<?=base_url()?>public/images/reload.png" alt="Reload"/></a> 
          </td> 
       </tr> 
      </tbody> 
     </table> 
     <input id="bt_submit" class="button" type="submit" value="<?=$this->lang->line('login_submit_button')?>" /> 
     </fieldset> 
    </form> 
    <p>&nbsp;</p> 
    <p>&nbsp;</p> 
     
    <script type="text/javascript"><!-- 
    //<![CDATA[ 
    function reload_page() 
    { 
        set_cookie('websam_lang', $F('lang'), 180, '/'); 
        window.location.reload(); 
    } 
     
    function do_login(valid, the_form) 
    { 
        if (valid) 
        { 
            the_form.getInputs('submit')[0].disable(); 
            $('login_status').hide(); 
             
            Control.Modal.open(false, { 
                      width: 200, 
                      height: 100, 
                      contents: function(){return $('leightbox').innerHTML;}, 
                      overlayCloseOnClick: false  
              }); 
                       
              new Ajax.Request(clean_url() + '/checklogin', { 
                              method: 'post', 
                              parameters: the_form.serialize(false), 
                              onSuccess: function (transport) { 
                                          set_cookie('websam_lang', $F('lang'), 180, '/'); 
                                          websam_url = clean_url().substring(0, clean_url().indexOf('login')); 
                                          window.location.replace(websam_url); 
                              }, 
                              onFailure: function (transport) { 
                                          $('login_status').show(); 
                                          $('login_status').innerHTML = get_error_message(transport.responseText); 
                                          the_form.getInputs('submit')[0].enable(); 
                                          the_form.focusFirstElement(); 
                                          Control.Modal.close(); 
                              }, 
                              onTimeout: function () { 
                                          $('login_status').show(); 
                                          $('login_status').innerHTML = get_error_message('<?=$this->lang->line('login_timeout')?>'); 
                                          the_form.getInputs('submit')[0].enable(); 
                                          the_form.focusFirstElement(); 
                                          Control.Modal.close(); 
                              } 
              }); 
        } 
        return false; 
    } 
     
    function ping() 
    { 
        $('login_status').hide(); 
        new Ajax.Request(clean_url() + '/ping', { 
                    method: 'get', 
                    onTimeout: function () { 
                            $('login_status').show(); 
                              $('login_status').innerHTML = get_error_message('<?=$this->lang->line('login_timeout')?>'); 
                    } 
        }); 
    } 
    setInterval('ping()', <?=( ($this->config->item('sess_expiration') * 1000) / )?>); 
     
    //Check if JS enabled 
    $('login_form').show(); 
    $('badbrowser').hide(); 
    $('user_id').activate(); 
     
    new Validation('login_form', {onFormValidate : do_login, useTitles : true}); 
     
    /* Mouse focus */ 
    function run_focus(e) 
    { 
        if (!window.event || /* Below is for IE*/ 
              (window.event.srcElement.id != 'user_id'  
               && window.event.srcElement.id != 'user_passwd' 
               && window.event.srcElement.id != 'lang') ) 
            $('user_id').focus(); 
    } 
     
    function AttachEvent(obj,evt,fnc,useCapture){ 
        if (!useCapture) useCapture=false; 
        if (obj.addEventListener){ 
            obj.addEventListener(evt,fnc,useCapture); 
            return true; 
        } else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc); 
        else{ 
            MyAttachEvent(obj,evt,fnc); 
            obj['on'+evt]=function(){ MyFireEvent(obj,evt) }; 
        } 
    }  
     
    //The following are for browsers like NS4 or IE5Mac which don't support either 
    //attachEvent or addEventListener 
    function MyAttachEvent(obj,evt,fnc){ 
        if (!obj.myEvents) obj.myEvents={}; 
        if (!obj.myEvents[evt]) obj.myEvents[evt]=[]; 
        var evts = obj.myEvents[evt]; 
        evts[evts.length]=fnc; 
    } 
    function MyFireEvent(obj,evt){ 
        if (!obj || !obj.myEvents || !obj.myEvents[evt]) return; 
        var evts = obj.myEvents[evt]; 
        for (var i=0,len=evts.length;i<len;i++) evts[i](); 
    } 
 
    AttachEvent($('user_id'), 'click', $('user_id').focus, true); 
<?php if (sizeof($enttable) != 1): ?> 
    AttachEvent($('user_passwd'), 'click', $('user_passwd').focus, true); 
<?php endif; ?> 
    AttachEvent($('lang'), 'click', $('lang').focus, true); 
    AttachEvent(document, 'click', run_focus, true); 
 
    //]]> 
    --></script> 
<?php $this->load->view('include/footer');?>

Last edited by chrishirst; 01-20-2010 at 06:52 AM..
addisonlai is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-19-2010, 10:03 PM Re: Fatal error: Using $this when not in object context
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
You can't use $this outside of a class declaration. In the future when you post code, use the php tags and indicate which line the error occurs on.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Reply     « Reply to Fatal error: Using $this when not in object context
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.40950 seconds with 12 queries