Welcome Guest, Not a member yet? Register   Sign In
problem with function model
#1

[eluser]linderox[/eluser]
I have working code on a localhost, but on a hosting it doesn't work. My browser show me just blank page without any HTML code. The problem in some relations with model.
If I put code from model to the controller everything shows me in the best way.

Code:
<?php

class Gallery extends Controller {

    function Gallery()
    {
        parent::Controller();    
    }
    
    function index()
    {                
        $data['title'] = "Rock Battle | Фотогалерея";
        $data['items'] = $this->gallery_model->getcategories();
        $this->load->view('gallery/index2', $data);
        $this->load->view('sidebar');        
    }    
}    
?>

Code:
<?php

class Gallery_model extends Model {

    function Gallery_model()
    {
        parent::Model();    
    }
    
    
    function getcategories()
        {
           $query = $this->db->get('photostock_catg');
           return $query->result_array();
        }
}
here is view/gallery/index2.php
Code:
<hr />
<div id="page">
             &lt;? foreach ($items as $row)    {            
                echo '<div class="photocategory"><div class="image"><div class="pic">';
                echo '<a href="'.base_url().'gallery/'.$row['alias'].'" src="'.base_url().$row['imgtitle'].'" alt="" width="260" height="173" class="left"></a>' ;
                echo '</div></div><div class="text">';
                echo '<a href="'.base_url().'gallery/'.$row['alias'].'" alt="'.$row['title'].'"><h1>'.$row['title'].'</h1></a>';
                echo '<p>'.$row['description'].'</p>';
                echo '</div><div class="clear"></div></div>';
            } ?&gt;
</div>
#2

[eluser]linderox[/eluser]
I have the similar code for feedback controller and it works well. I don't know why.
on the localhost there is winxp on a hosting there is a linux system
#3

[eluser]Thorpe Obazee[/eluser]
What does it show you when you comment out the line with getcategories() ?
#4

[eluser]linderox[/eluser]
it shows me some html code as it written in this views:
Code:
$data['title'] = "Rock Battle | Фотогалерея";
        //$data['items'] = $this->gallery_model->getcategories();
        $this->load->view('gallery/index2', $data);
        $this->load->view('sidebar');
#5

[eluser]Thorpe Obazee[/eluser]
I meant what does your browser 'show'? could you paste what shows out of your snippet?
#6

[eluser]linderox[/eluser]
there is a problem in mvc system. I can't get any function from that gallery_model. Everytime when I try it receive me just blank page
#7

[eluser]linderox[/eluser]
the problem in some relations with model.
If I put code from model to the controller everything shows me in the best way.
#8

[eluser]Evil Wizard[/eluser]
[quote author="linderox" date="1243919552"]I have working code on a localhost, but on a hosting it doesn't work. My browser show me just blank page without any HTML code. The problem in some relations with model.
If I put code from model to the controller everything shows me in the best way.

Code:
&lt;?php

class Gallery extends Controller {

    function Gallery()
    {
        parent::Controller();    
    }
    
    function index()
    {                
        $data['title'] = "Rock Battle | Фотогалерея";
        $data['items'] = $this->gallery_model->getcategories();
        $this->load->view('gallery/index2', $data);
        $this->load->view('sidebar');        
    }    
}    
?&gt;

Code:
&lt;?php

class Gallery_model extends Model {

    function Gallery_model()
    {
        parent::Model();    
    }
    
    
    function getcategories()
        {
           $query = $this->db->get('photostock_catg');
           return $query->result_array();
        }
}
here is view/gallery/index2.php
Code:
<hr />
<div id="page">
             &lt;? foreach ($items as $row)    {            
                echo '<div class="photocategory"><div class="image"><div class="pic">';
                echo '<a href="'.base_url().'gallery/'.$row['alias'].'" src="'.base_url().$row['imgtitle'].'" alt="" width="260" height="173" class="left"></a>' ;
                echo '</div></div><div class="text">';
                echo '<a href="'.base_url().'gallery/'.$row['alias'].'" alt="'.$row['title'].'"><h1>'.$row['title'].'</h1></a>';
                echo '<p>'.$row['description'].'</p>';
                echo '</div><div class="clear"></div></div>';
            } ?&gt;
</div>
[/quote]
I notice that in your controller you are not loading the model, is the model being autoloaded? Also you could check the server logs just after a white page (/var/logs/httpd/error_log) to see if there was a php error logged, alternatively use
Code:
if(1) {
    ini_set('display_errors', 'on');
    error_reporting(E_ALL);
}
This should allow error reporting on your live host, just remember to remove the snippet when you have finished debugging, or change the "1" to a "0"
#9

[eluser]linderox[/eluser]
apache error log
Code:
[Wed Jun 03 12:28:15 2009] [error] [client 217.65.213.123] PHP Fatal error:  Class 'Gallery_model' not found in /usr/home/22183/rb.torrio.ru/html/system/libraries/Loader.php on line 184
#10

[eluser]Evil Wizard[/eluser]
f you are using a linux server then it could be that the filename "Gallery_model.php" is not where CI thinks it should be. The file name is case sensitive in that environment, however class and function names in php are case insensitive.




Theme © iAndrew 2016 - Forum software by © MyBB