Question

I am trying to load a view from constructor with parameter $data. Earlier it was working fine and now suddenly it stopped working. Below is the code:

permissionerror View

    <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td width="6" align="left" valign="top" background="<?php echo base_url();?>images/bg/topbg.gif"><img src="<?php echo base_url();?>images/bg/top-left.gif" width="5" height="34" /></td>
                <td height="34" align="left" valign="middle" background="<?php echo base_url();?>images/bg/topbg.gif" class="heading">Access Forbidden</td>
                <td width="6" align="right" valign="top" background="<?php echo base_url();?>images/bg/topbg.gif"><img src="<?php echo base_url();?>images/bg/top-right.gif" width="5" height="34" /></td>
              </tr>
              <tr>
                <td align="left" valign="top" background="<?php echo base_url();?>images/bg/main-content-bg-left.gif">&nbsp;</td>
                <td height="165" valign="top"  bgcolor="#FFFFFF" class="leftredheading"><div style="margin:30px auto;padding-left:15px"><? if(isset($sn_error)) echo $sn_error;?></div></td>
                <td align="right" valign="top" background="<?php echo base_url();?>images/bg/main-content-bg-right.gif">&nbsp;</td>
              </tr>
              <tr>
                <td align="left" valign="bottom" background="<?php echo base_url();?>images/bg/bottom-bg.gif"><img src="<?php echo base_url();?>images/bg/bottom-left-corner.gif" width="5" height="5" /></td>
                <td valign="top" background="<?php echo base_url();?>images/bg/bottom-bg.gif"></td>
                <td align="right" valign="bottom" background="<?php echo base_url();?>images/bg/bottom-bg.gif"><img src="<?php echo base_url();?>images/bg/bottom-right-corner.gif" width="5" height="5" /></td>
              </tr>
            </table>

Template code:

<?php $this->load->view('includes/login/header'); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#e7e7de">
  <tr>
    <td width="18"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
    <td width="191"><img src="<?php echo base_url();?>images/bg/zero.gif" width="191" height="1" /></td>
    <td width="18"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
    <td width="100%">&nbsp;</td>
    <td width="161"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
    <td width="191"><img src="<?php echo base_url();?>images/bg/zero.gif" width="191" height="1" /></td>
    <td width="18"><img src="<?php echo base_url();?>images/bg/zero.gif" width="18" height="1" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="left" valign="top"><table width="191" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif"> <?php $this->load->view('includes/login/top_right'); ?> </td>
      </tr>
      <tr>
        <td height="50" background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif">&nbsp;</td>
      </tr>
      <tr>
        <td background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif"><table width="166" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td align="left" valign="top"><img src="<?php echo base_url();?>images/bg/needhelp-top.gif" width="166" height="7" /></td>
          </tr>
          <tr>
            <td align="center" valign="top" bgcolor="#F8F7EC"> <?php $this->load->view('includes/login/bottom_right'); ?>
                <br /></td>
          </tr>
          <tr>
            <td align="left" valign="top" bgcolor="#F8F7EC"><img src="<?php echo base_url();?>images/bg/needhelp-bottom.gif" width="166" height="7" /></td>
          </tr>
        </table>
          <br /></td>
      </tr>
      <tr>
        <td background="<?php echo base_url();?>images/bg/left-menu-white-bg.gif"><table width="191" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="6" align="left" valign="top"><img src="<?php echo base_url();?>images/bg/left-bttom.gif" width="6" height="6" /></td>
            <td width="100%" background="<?php echo base_url();?>images/bg/leftbottom.gif"></td>
            <td height="6" align="right" valign="top"><img src="<?php echo base_url();?>images/bg/right-bttom.gif" width="6" height="6" /></td>
          </tr>
        </table></td>
      </tr>
    </table>
         <br /></td><td>&nbsp;</td>
    <td valign="top"  <? if($main_content != 'dashboard' || $main_content == 'publisher_dashboard') { ?> colspan="3" <? } ?>><?php $this->load->view($main_content); ?></td>
    <td>&nbsp;</td>
    <? if($main_content == 'dashboard' || $main_content == 'publisher_dashboard') { ?>
    <td align="right" valign="top"> <?php $this->load->view('includes/login/left'); ?>
    </td>
    <? } ?>
    <td>&nbsp;</td>
  </tr>
</table>
<?php $this->load->view('includes/login/footer'); ?>

Here in the above code i am checking whether logged in user is having permission for access then do else part otherwise through the error from if case block.

In IF case it loads the error template.

Please somebody help me to fix the above issue ASAP!

Was it helpful?

Solution

Call parent::__construct(), not parent::Controller().

Edit:

After it was made clear that CodeIgniter 1.7.1 is used and after the view itself was shown, this is your issue:

Your view tries to echo $error instead of $sn_error. If you don't pass $data to the view, then $sn_error (which is checked for) isn't set and that error doesn't occur - that's why the view gets loaded in that case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top