CodeIgniter Forums
Can't finish tutorial. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Can't finish tutorial. (/thread-61490.html)



Can't finish tutorial. - weaboo - 04-19-2015

I tried to pass a Codeigniter tutorial at http://www.codeigniter.com/user_guide/tutorial/news_section.html
seems I did all step by step from the guide, but I met 2 problems. When I filled some stuff to data base, and created 2 news manually, and tried to click "View article" [attachment=170], it sends me to index.php/1st and shows me 404 error [attachment=171].

By tinkering around I found that article actually exist,[attachment=172] but it has different adress /index.php/news/1st. But I don't know why it's broken and how to fix it.
Is tutorial guide old and out-of-date, or I failed?

Also same problem with the http://www.codeigniter.com/user_guide/tutorial/create_news_items.html
when I finished it, [attachment=173] I can't add news through web-form. It sends me to 404 page [attachment=174] with ridiculous adress.

Ty for attention.


RE: Can't finish tutorial. - webnaz - 04-19-2015

Actually you have one error only.
Your "first" error is not an error, that is how codeigniter urs works, see http://www.codeigniter.com/user_guide/general/urls.html

For your "second" error check your form_open
try changing it to
PHP Code:
<?php echo form_open('http://ci.local/index.php/news/create'?>



RE: Can't finish tutorial. - ChicagoPhil - 04-19-2015

(04-19-2015, 01:34 PM)weaboo Wrote: I tried to pass a Codeigniter tutorial at http://www.codeigniter.com/user_guide/tutorial/news_section.html
seems I did all step by step from the guide, but I met 2 problems. When I filled some stuff to data base, and created 2 news manually, and tried to click "View article" , it sends me to index.php/1st and shows me 404 error .

By tinkering around I found that article actually exist, but it has different adress /index.php/news/1st. But I don't know why it's broken and how to fix it.
Is tutorial guide old and out-of-date, or I failed?

Also same problem with the http://www.codeigniter.com/user_guide/tutorial/create_news_items.html
when I finished it,  I can't add news through web-form. It sends me to 404 page  with ridiculous adress.

Ty for attention.


Try going into your application/config/config.php file and setting your $config['base_url']= 'your_base_url' and your $config['index_page']=' ' <---------- take index.php out so the value is empty.


RE: Can't finish tutorial. - ChicagoPhil - 04-19-2015

I just did the tutorial and there is a slight error in the views/news/index.php file. In the anchor tag on line 9 it should be like this:

<p><a href="<?php echo 'news/'.$news_item['slug'] ?>">View article</a></p>

instead of:

<p><a href="<?php echo $news_item['slug'] ?>">View article</a></p>


RE: Can't finish tutorial. - Muzikant - 04-20-2015

It was changed, because in our case it worked in opposite way: Userguide CI 3.0 error.


RE: Can't finish tutorial. - ChicagoPhil - 04-20-2015

(04-20-2015, 12:04 AM)Muzikant Wrote: It was changed, because in our case it worked in opposite way: Userguide CI 3.0 error.

Edited... I ate my words.


Upon further inspection, I now understand the problem. You are routing the first segment to (:any) for the static pages and then overriding that setting with the $config['news'] = 'news'

That is a bit confusing for a introductory tutorial.

I'm standing by my first post though, I believe it's correct.


RE: Can't finish tutorial. - ChicagoPhil - 04-20-2015

Ok so if you are in the browser and you have this:
http://localhost/cms2/news
in the URL

Then you need the link with the news in front of it.

However if you have this:
http://localhost/cms2/news/
in the URL

You need the link with out the word news in it.


RE: Can't finish tutorial. - alkarim - 04-21-2015

Juz follow the instruction properly and make sure and double check before posting in forum Smile