Welcome Guest, Not a member yet? Register   Sign In
Cannot load views when running xampp
#1

[eluser]WavyDavy[/eluser]
I am trying to follow this tutorial here and I cannot load any views.
codeigniter-from-scratch-day-1/

I can echo no problems but I cant do anything else. Is my code ok or do I need to configure something in xampp?

This is the code for my controller site.php;
Code:
<?php
class Site extends Controller {

  function index() {
    $this->load->view('home');
  }

}
?>

And this is the code for my view home.php
Code:
<html>
<head>
<title>My Site</title>
</head>
<body>
    <h1>I have loaded my first view!</h1>
&lt;/body&gt;
&lt;/html&gt;
I am running XAMPP 1.7.3 on Windows XP Pro using version 1.7.2 of Codeigniter, site.php is in the controllers folder and home.php is in the views folder.
#2

[eluser]Cro_Crx[/eluser]
Your Site controller needs to have a constructor. Like this:

Code:
&lt;?php
class Site extends Controller
{

  function Site()
  {
    parent::Controller();
  }

  function index()
  {
    $this->load->view('home');
  }

}

It's good practice to leave out the ending ?&gt; tag on your code. http://ellislab.com/codeigniter/user-gui...losing_tag
#3

[eluser]WavyDavy[/eluser]
Thanks for your reply.

I tried the code you gave but unfortunately it doesnt fix the problem.

Maybe there is something I need to config in the config folder or maybe this problem is a bug with 1.7.2?
#4

[eluser]flaky[/eluser]
make this little test
Code:
function index()
  {
    $test = $this->load->view('home', '', TRUE);
    echo $test;
  }

and put the result here
#5

[eluser]WavyDavy[/eluser]
I tried the test and got a 404 page
#6

[eluser]flaky[/eluser]
it looks like codeigniter can't find your view, either the file name is wrong or you placed it somewhere else.
#7

[eluser]WavyDavy[/eluser]
Its in my views folder, is that the right place for it?
#8

[eluser]flaky[/eluser]
if it is in
Code:
system\application\views\
then yes
#9

[eluser]WavyDavy[/eluser]
Here is a link to a screenshot of how my folders are setup.

I have tried moving the application folder back inside of the systems folder but that doesnt seem to fix it either.

I will try setting up a new Codeigniter directory from scratch.
#10

[eluser]flaky[/eluser]
Next time don't forget to mention the "small" details (that you've moved the application folder and other stuff)




Theme © iAndrew 2016 - Forum software by © MyBB