I am starting to learn codeigniter. I get this error while trying to run the project.
Parse error: syntax error, unexpected '$this' (T_VARIABLE), expecting ';' or '{' in C:\xampp\htdocs\Codeigniter\application\models\post.php on line 5
My Model-post.php:
class Post extends CI_Model{
function get_posts($num=20, $start=0)
$this->db->select()->from('posts')->where('active',1)->order_by('date_added','desc')->limit($start,$num);
$query=$this->db->get();
return $query->result_array();
}
}
My Controller-posts.php:
<?php
class Posts extends CI_Controller{
function index(){
$this->load->model('post');
$data['posts'] = $this->post->get_posts();
print_r($data['posts']);
}
}
function get_posts($num=20, $start=0)
with this one:function index(){
– Rizier123 Feb 18 '15 at 10:10function get_posts($num=20, $start=0)
. You declare a function without opening the brace. Add the opening brace like thisfunction get_posts($num=20, $start=0) {
It's surprising you didn't open the brace, yet you are closing it on the second-to-last line. – Michael Woyo Feb 18 '15 at 10:11