Codeigniter урок4 an uncaught exception was encountered. что делать?

0

Прохожу модуль CodeIgniter урок4. Делаю по аналогии, но со своими названиями.

В браузере ввожу http://khvoya.com/index.php/products/view/product-2. Выводит такую ошибку

An uncaught Exception was encountered. 

Type: ParseError

Message: syntax error, unexpected '404' (T_LNUMBER)

Filename: C:\xampp\htdocs\Khvoya\application\controllers\Products.php

Line Number: 26

Backtrace:

File: C:\xampp\htdocs\Khvoya\index.php
Line: 315
Function: require_once

Код контроллера Products.php

<?php

defined('BASEPATH') OR exit ('No direc script access allowed');

class Products extends CI_Controller {

	public function __construct () {
		parent::__construct();
		$this->load->model('Product_model');
	}

	public function index() {
		$data['title'] = "Все продукты";
		$data['products'] = $this->Product_model->getProducts();

		$this->load->view('templates/header', $data);
		$this->load->view('products/index', $data);
		$this->load->view('templates/footer');

		}

	public function view($slug = NULL) {
		$data['products_item'] = $this->Product_model->getProducts($slug);

		if(empty($data['products_item'])) {
			show 404();
		}

		$data['title'] = $data['products_item']['name'];
		$data['content'] = $data['products_item']['image'];

		$this->load->view('templates/header', $data);
		$this->load->view('products/view', $data);
		$this->load->view('templates/footer');
	}


}

Код routes.php

$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

$route['products'] = 'products';
$route['products/(:any)'] = 'products/view/$1';

Product_model.php

<?php

class Product_model extends CI_Model {

	public function __construct() {
		$this->load->database();
	}

	public function getProducts($slug = FALSE) {
		if($slug === FALSE) {
			$query = $this->db->get('products');
			return $query->result_array();
		}

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

Помогите пожалуйста!

CodeIgniter

1 ответов

1

Нашла ошибки!

Sign up or Log in to write an answer