Blog in 20 minutes video tutorial? Maybe 240 or 380 minutes |
[eluser]soyraro[/eluser]
Hi all, I'm newbie into Codeigniter and I find is an excellent piece of software, I was pretty excited about using it, but now I am a little bit dissapointed. This is my first php framework, trying to accomplish the video tutorial "blog in 20 minutes" and I am stuck... again, first I noticed that the video tutorial doesn't speak about creating a model for the controller is necessary, so when talks about putting... $data['query'] = $this->db->get('entries'); into the blog controller it didn't worked for me... after hours of searching I realize that I had to create a blog_model and create an function get_entries() { $query = $this->db->get('entries'); return $query->result(); } and replacing $data['query'] = $this->db->get('entries'); for $data['query'] = $this->blog_model->get_entries(); Well... It took more or less four hours of headache But now I am stuck in the function comments(), I get a 404 page, the url helper gives me the right link http://localhost/codeigniter_test/index....comments/1 I have tried to change the $config['uri_protocol'] = "AUTO"; to every parameter and doesn't work, I have tried to change $config['base_url'] = "http://localhost/codeigniter_test"; with slash at the end and without... nothing I have tried to create a comment model and nothing. this is my comments function in the blog controller function comments() { $data['titlepag'] = 'My Comment Title'; $data['headingpag'] = 'My Comment Heading'; //echo $this->comment_model->test(); $this->load->view('comment_view', $data); } It wouldn't be better to have an html updated tutorial than a video outdated tutorial? If somebody can help me I would really appreciate it. I am using XAMPP and Aptana IDE in an Apple environment. Thanks
[eluser]Phil Sturgeon[/eluser]
DB interaction works perfectly fine in the controller but SHOULD be done in the model. It didnt mention it because its not a requirement. It is perfectly possible to do the 20 minute tutorial in 20 minutes.
[eluser]soyraro[/eluser]
Sorry but in my case it didn't work the db interaction... following the tutorial I always get an error using it A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: views/blog_view.php Line Number: 9 Thats why I am using the model
[eluser]Phil Sturgeon[/eluser]
Using a model you are just changing the location of the same code, something else is going wrong here.
[eluser]jedd[/eluser]
[quote author="soyraro" date="1259442229"]any clue?[/quote] Any code? You've said an error occurred at line 9 of a file .. that you haven't shown us. Are you loading the database class?
[eluser]soyraro[/eluser]
Yes, I am loading the database class in autoload.php $autoload['libraries'] = array('database'); Ok I explain what I did... I followed the video tutorial and I founded an error where the tutorial says... $data['query'] = $this->db->get('entries'); in function index of the controller... when trying to load the blog_view that said <html> <head> <title><?=$titlepag?></title> </head> <body> <h1><?=$headingpag?></h1> <?php foreach($query as $row): ?> <h3><?= $row->title ?></h3> <h3><?= $row->body ?></h3> <p><?= anchor('blog/comments/' . $row->id ,'Comments') ?></p> <hr></hr> <?php endforeach; ?> </body> </html> It said A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object Filename: views/blog_view.php Line Number: 9 In every blog entry so I created the blog_model and It worked so I followed the tutorial again till I have found another error about listing the comments (if you read first post)... do you want me to post my files? Thanks
[eluser]überfuzz[/eluser]
Welcome to this forum soyrar! Edit your posts like this. 1. Scroll to your last post. 2. Click [edit] 3. Highlight the code in your post 4. Click [code] 5. Click [update post]
[eluser]clip[/eluser]
Try this Code: <?php foreach($query as $row): ?>
|
Welcome Guest, Not a member yet? Register Sign In |