Welcome Guest, Not a member yet? Register   Sign In
[Solved] View fails to load:
#1

[eluser]mdumont[/eluser]
Hey Guys,

So I just started using CodeIgniter a week or so ago. I spent some time looking through the user manual, but couldn't find much that described the problem I'm having.

I have a very basic controller that is loading a view of mine, however when I browse to the page, all I get is a blank page. Looking at the source, the only thing that has loaded is the <html><head>.

I'm fairly new to web development overall, so I'm not really sure where to begin debugging this problem.

Thanks for the assistance!

-Mike
#2

[eluser]dark_lord[/eluser]
Can you at least post your sample source code? It could be much easier for the community to address your issues. :-)
#3

[eluser]mdumont[/eluser]
Sorry... :-(

Here is the controller that I'm using (this is set as the default as well):
Code:
<?php

class Home extends Controller {

    function Home()
    {
        parent::Controller();
        $this->load->helper('book');
    }

    function index()
    {
        $data['admin'] = ldap_book_auth($_SERVER['WEBAUTH_USER']);
        $this->load->view('home_view',$data);
        return;
    }
}

?>

and the view:
Code:
<html>
    <head>
        <link rel="stylesheet" href='<?=base_url();?>css/style.css' type="text/css">
        <title>CSH Book Database</title>
    </head>
    <body>
        <div id="header">
            <div class="title">
                books.csh
            </div>
            <div class="navbar">
                <div class="navitem"><a href="&lt;?=base_url();?&gt;home">HOME</a></div>
                <div class="navitem"><a href="&lt;?=base_url();?&gt;request">REQUEST</a></div>
                <div class="navitem"><a href="&lt;?=base_url();?&gt;library">LIBRARY</a></div>

                &lt;?php if($admin):?&gt;
                    <div class="navitem"><a href="&lt;?=base_url();?&gt;admin">ADMIN</a></div>
                &lt;?php endif; ?&gt;

            </div>
            <div class="status">
                <div class="status_item">Logged in as: mdumont</div>
                <div class="status_item">Reviews Due:</div>
                <div class="status_item">Books In Queue:</div>
            </div>
        </div>
        <div id="layout">
            <div id="left" class="column">
            </div>



        </div>

    &lt;/body&gt;
&lt;/html&gt;
#4

[eluser]dark_lord[/eluser]
Can you try removing the return?

Code:
function index()
    {
        $data['admin'] = ldap_book_auth($_SERVER['WEBAUTH_USER']);
        $this->load->view('home_view',$data);
        #return;
    }
#5

[eluser]mdumont[/eluser]
Doh... yeah, the return wasn't originally there... I had thrown it in on a whim to see what would change, it fails to load regardless.

-Mike
#6

[eluser]xeroblast[/eluser]
try something like this if it view something...

Code:
function index()
{
  echo 'anything';
  // your code here
}

if that anything is display in your browser then there is something wrong in your construct...
AND never heard a $this->load->helper('book'); unless you create a helper 'book_helper.php'...
#7

[eluser]mdumont[/eluser]
Yeah, this program is being used to manage a library of books for an organization.

I put in the echo and that showed.

I then stripped away everything from the constructor except the parent::Controller(); line and just passed admin = true to my view and it still shows the echo statement in my browser.

-Mike
#8

[eluser]xeroblast[/eluser]
try this if both of them displayed...

Code:
function index()
    {
        $data['admin'] = ldap_book_auth($_SERVER['WEBAUTH_USER']);
        echo 'anything1';
        $this->load->view('home_view',$data);
        echo 'anything2';
        return;
    }
#9

[eluser]mdumont[/eluser]
Yeah, so I changed that a little... I tried one before the ldap_auth, between the auth and the view, and after the view.

Both things before the view printed correctly.... I'm guessing its an issue with my view... but god knows what it is...

Also, it appears if I rename that view file to be named as one of my currently working views, it loads fine from the other controller....

No idea what's going on now.

-Mike
#10

[eluser]xeroblast[/eluser]
ok... i already encountered that problem before and here is an easy way to do it...

if you are NOT using the php shorthand (&lt;? ?&gtWink, try to find all '&lt;?php ' (with space) and replace it with '&lt;?php // '...
if you are using shorthand, replace '&lt;?' (no space) to '&lt;? //'...
or simply comment all php code...

after you do this... remove the comment (//) one-at-a-time to identify which one of the code is giving errors...

goodluck...




Theme © iAndrew 2016 - Forum software by © MyBB