Welcome Guest, Not a member yet? Register   Sign In
View file not being served from the controller
#1

[eluser]dgriffter[/eluser]
Hi,

I have a problem. I have copied a Coedigniter site from a live server where it is working fine and have installed it on my local machine. However, the view file is not being served from the controller. The controller is accessing the database, but the view file html is not showing up in the browser. I feel sure it must be something to do with either a config file or a server httpconf setting, but I have no idea where. Does anyone recognise this or have any ideas?

Thank you all in advance....

Dgriffter

UPDATE: I'm running Apache on port 8080 (IIS on port 80). I have set the $config['base_url'] to reflect this ("http://localhost:8080/ci/"). I also have the db settings correct, as I'm getting feedback in the controller file
#2

[eluser]xwero[/eluser]
You didn't see the initial welcome message or is it a controller method you added yourself? If it's the latter is it possible to see your controller code?
#3

[eluser]dgriffter[/eluser]
the code is as follows:

<?php

class main extends Controller {

function main(){
parent::Controller();
$this->load->library('session');
$this->load->helper('url');
$this->load->helper('form');
$this->load->library('email');
}

function index(){

//echo 'test text ';
$session_id = $this->session->userdata('session_id');
$data['session_id']=$session_id ;
$data['title']='Page Title';
$data['query']= $this->db->query("SELECT * FROM family ORDER BY idfamily asc");
$data['query2']= $this->db->query("SELECT * FROM subfamily ORDER BY idsubfamily asc");


if ($data['query2']->num_rows() > 0)
{
$row = $data['query2']->row();
echo $row->idsubfamily;

}


$data['query3']= $this->db->query("SELECT * FROM product WHERE idsubfamily=".$row->idsubfamily." ");
$this->load->view('main_view', $data);
}

}
?>



The echo $row->idsubfamily; returns 23, the correct id from the database, but the $this->load->view('main_view', $data); doesn't display the main_view.php file, which is full of html and other stuff.

Thank you for looking,

Dgriffter
#4

[eluser]xwero[/eluser]
your controller code looks fine. And you have a main_view.php file in your views directory?
You could try the view without the $data argument to be sure.
#5

[eluser]dgriffter[/eluser]
The main_view file is in the views directory and I have tested without the $data argument.

I feel sure this is an issue with my server setup. I have other sites running on my local server and they are all fine.

Thank you for your response,

Dgriffter
#6

[eluser]dgriffter[/eluser]
Basically, none of the view files are being served from the controllers. I'm getting rather desperate as I have to test this web app and I can't even get the view files to load.

Dgriffter
#7

[eluser]dgriffter[/eluser]
I checked the log files, there was a php endforeach error - the server where the program is hosted uses php4 and mine is php5 - could this be the problem? I have created a very simple main_view.php file with basic html and this renders fine... looks like I won't be able to test locally using my server setup as it is. Is there any way I can test on php4 locally without altering my server setup? I did read about this wamp or something... perhaps that would be easy to install and sort out?


Thank you all,

Dgriffter
#8

[eluser]xwero[/eluser]
This is something strange. try to search the forum if someone else experienced the same error before otherwise you should post a new topic in the bug section. That is the best advise i can give you at the moment, i'm sorry.
#9

[eluser]dgriffter[/eluser]
The original code has been written in a mixture of short and long php tags - would this affect the proper working of the view pages? Imo it's sloppy coding, but I'm not the code parser. I will try to make a few adjustments and see what happens.

Thank you once again for your comments and help,

Dgriffter
#10

[eluser]dgriffter[/eluser]
is there such thing as a closing foreach tag - <?php endforeach;?> ?




Theme © iAndrew 2016 - Forum software by © MyBB