Welcome Guest, Not a member yet? Register   Sign In
Tutorial − News section error
#1

[eluser]Unknown[/eluser]
I,m going through the News section tutorial and I am getting an error following the instructions. Does anyone know why this is?

Open up the application/models directory and create a new file called news_model.php and add the following code. Make sure you've configured your database properly as described here.
Code:
<?php
class News_model extends CI_Model {

public function __construct()
{
  $this->load->database();
}
}
Now that the database and a model have been set up, you'll need a method to get all of our posts from our database. To do this, the database abstraction layer that is included with CodeIgniter — Active Record — is used. This makes it possible to write your 'queries' once and make them work on all supported database systems. Add the following code to your model.
Code:
public function get_news($slug = FALSE)
{
if ($slug === FALSE)
{
  $query = $this->db->get('news');
  return $query->result_array();
}

$query = $this->db->get_where('news', array('slug' => $slug));
return $query->row_array();
}

Adding the second block of code to news_model.php produces a syntax error on line
Code:
public function get_news($slug = FALSE)




Theme © iAndrew 2016 - Forum software by © MyBB