• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Page not found error in create a news tutorial

#11
[eluser]InsiteFX[/eluser]
Try setting it like this
Code:
$config['base_url'] = 'http://www.abc.com/';

#12
[eluser]Unknown[/eluser]
i am here to learn from you.

#13
[eluser]StevenTen[/eluser]
[quote author="InsiteFX" date="1331866459"]Try setting it like this
Code:
$config['base_url'] = 'http://www.abc.com/';
[/quote]


It works!! Looks like I need to follow the rule strictly, THanks InsiteFX !!

#14
[eluser]Unknown[/eluser]
[quote author="InsiteFX" date="1331866459"]Try setting it like this
Code:
$config['base_url'] = 'http://www.abc.com/';
[/quote]

This worked for my install as well, you still need to use protocol even for local environments.

Seemed easy enough, compared to Zend's tutorial, this is a cake walk in no more than 7 functions if fact. The only thing I'm skeptical about is the routing and how Google likes the way Codeigniter handles permalinks.

#15
[eluser]Unknown[/eluser]
For beginners like me, who are using WAMP and are receiving the same error as that on the top where the url seems to be concatenated or doubled after clicking submit, the error was because of the base url being set by you, which was instructed in the tutorial as a must.

I also solved this problem thanks to the solution shown by InsiteFX there, to just leave the base url in the application\config\config.php as blank.

#16
[eluser]soluicius[/eluser]
I have the same problem as above.
This is my htaccess:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.

    ErrorDocument 404 /index.php
</IfModule>


news_model.php:
Code:
&lt;?php

class News_model extends CI_Model {

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

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

public function set_news() {

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

$slug = url_title($this->input->post('title'), 'dash', TRUE);

$data = array(
  'title' => $this->input->post('title'),
  'slug' => $slug,
  'text' => $this->input->post('text')
);

return $this->db->insert('news', $data);
}
}

?&gt;

news.php:
Code:
&lt;?php


class News extends CI_Controller {

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

public function index(){

$data['news'] = $this->news_model->get_news();
$data['title'] = 'News archive';

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

public function view($slug) {
$data['news_item'] = $this->news_model->get_news($slug);

if (empty($data['news_item'])) {
  show_404();
}

$data['title'] = $data['news_item']['title'];

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

public function create() {

$this->load->helper('form');
$this->load->library('form_validation');

$data['title'] = 'Create a news item';

$this->form_validation->set_rules('title', 'Title', 'required');
$this->form_validation->set_rules('text', 'text', 'required');

if ($this->form_validation->run() === FALSE) {
  
  $this->load->view('templates/header', $data);
  $this->load->view('news/create');
  $this->load->view('templates/footer');

} else {
  $this->news_model->set_news();
  $this->load->view('news/success');
  }
}
}

Code:
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];

Code:
$route['news/create'] = 'news/create';
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';
$route['404_override'] = '';


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.