Welcome Guest, Not a member yet? Register   Sign In
Updated News Tutorial
#7

(This post was last modified: 09-18-2016, 03:59 AM by InsiteFX. Edit Reason: add any routes )

This is wrong in the News Tutorial:

PHP Code:
// Tutorial is wrong here!

$this->load->helper('url_helper');

// should be

$this->load->helper('url');

// you have an error here

class News_model extends CI_Model {

 
   public function __construct()
 
   {
        $this->load->database();
    }
// <-- remove this its an extra one...

 
   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();


Most people do not catch it because they autoload the url helper in ,/application/autoload.php

Also in your routes you need to move all routes with a /(:any) in them to the bottom,
the any is a catch all route and no routes after it will run.

This error is usually syntax error: Missing bracket, too many closing brackets, etc;
Message: syntax error, unexpected 'public' (T_PUBLIC)
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
Updated News Tutorial - by cisite - 01-31-2016, 11:39 PM
RE: Updated News Tutorial - by cisite - 02-02-2016, 03:01 PM
RE: Updated News Tutorial - by Paradinight - 02-07-2016, 10:08 AM
RE: Updated News Tutorial - by RobertSF - 02-07-2016, 06:08 PM
RE: Updated News Tutorial - by InsiteFX - 02-08-2016, 05:00 AM
RE: Updated News Tutorial - by josemg - 09-17-2016, 07:50 PM
RE: Updated News Tutorial - by InsiteFX - 09-18-2016, 03:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB