Welcome Guest, Not a member yet? Register   Sign In
can't even get thru tutorial without errors
#11

[eluser]terionm[/eluser]
its confusing to me that you don't have to declare the field names? is that right?
#12

[eluser]Cristian Gilè[/eluser]
The model name can't be the same of the controller name. The users_model.php is right. Load it as:

Code:
$this->load->model('users_model');

and call its functions as:
Code:
$this->users_model->function_name();


Cristian Gilè
#13

[eluser]terionm[/eluser]
where are the best tutorials obviously the devshed ones suck and don't work.

now I get this error:

Fatal error: Class 'Users_model' not found in C:\xampp\htdocs\auto\system\libraries\Loader.php on line 184

someone told me learning php is easy using this framework
#14

[eluser]Cristian Gilè[/eluser]
http://net.tutsplus.com/articles/news/co...tch-day-1/

Cristian Gilè
#15

[eluser]terionm[/eluser]
starting to think I am missing something in my installation...it all looks right but even following along with the video tutorials and using the code that come with them I am getting errors like this

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Site_model::$db

Filename: models/site_model.php

and yes I did copy all the library files over into the application/library folder etc...
#16

[eluser]Cristian Gilè[/eluser]
Have you loaded the database library?

http://ellislab.com/codeigniter/user-gui...cting.html


Cristian Gilè
#17

[eluser]terionm[/eluser]
yep in my config I did do that ..


odd thing too, is it is returning the error twice --- one for each record in the db table...but won't load the table results here is all my code....

controller
Code:
<?php

class Site extends Controller {
    
    function index() {
        $this->load->model('site_model');
        $data['records'] = $this->site_model->getAll();
        $this->load->view('home', $data);
    }
    
}

Model:
Code:
<?php

class Site_model extends Model {
    
    function getAll() {
        $q = $this->db->get('users');
        
        if($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                $data[] = $row;
            }
        return $data;
        }
    }
    
    
}

view:
Code:
<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  
  <body>
    <div id="container">
        <p>My view has been loaded</p>
        
        &lt;?php foreach($records as $row) : ?&gt;
            <h1>&lt;?php echo $row->users; ?&gt;</h1>
        &lt;?php endforeach; ?&gt;
    </div>
  &lt;/body&gt;
&lt;/html&gt;
#18

[eluser]Cristian Gilè[/eluser]
Have you autoloaded it in the autoload.php file?
Code:
$autoload['libraries'] = array('database');


Cristian Gilè
#19

[eluser]terionm[/eluser]
yep it's autoloaded and my other config file is set up for my db etc...
#20

[eluser]terionm[/eluser]
WWWOOOHOOOO I got it...I goofed the field name in the view file instead of users should of been username...it friggin is working...jeeesh only took all day lmao.




Theme © iAndrew 2016 - Forum software by © MyBB