Welcome Guest, Not a member yet? Register   Sign In
Blog Video Tutorial - Is it still possible to complete?
#1

[eluser]Unknown[/eluser]
Hi there,

I've be running through both video tutorials for CI fine. I am now on tutorial 2, making the blog.

I am up the part where the entries table is made, and we have just used the scaffolding feature to enter two blog entries.

Now this is done, and we adjust our blog class to look like this:

Code:
class Blog extends Controller {
  
  function Blog()
  {
    parent::Controller();
  }
  
  function index()
  {    
    $data['title'] = "My Blog Title";
    $data['heading'] = "My Blog Heading";
    $data['query'] = $this->db->get('entries');
    
    $this->load->view('blog_view', $data);
  }
  
}

And our blog_view.php code to look like this:

Code:
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<h1>&lt;?php echo $heading; ?&gt;</h1>

  &lt;?php print_r($query); ?&gt;
  
  &lt;?php foreach($query as $row): ?&gt;
  
   <h3>&lt;?php echo $row->title; ?&gt;</h3>
   <p>&lt;?php echo $row->body; ?&gt;</p>
  
   <hr />
  
  &lt;?php endforeach; ?&gt;

&lt;/body&gt;
&lt;/html&gt;

I have picked this code to pieces for about an hour and can find no problem. But when you actually view the blog, All I get is 14 of these errors:

A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: views/blog_view.php
Line Number: 12

If I do a print_r on $query in the view, I get this:

CI_DB_mysql_result Object ( [conn_id] => Resource id #28 [result_id] => Resource id #32 [result_array] => Array ( ) [result_object] => Array ( ) [current_row] => 0 [num_rows] => 2 [row_data] => )

So nothing is being returned, and to be honest, looking at that output, I can't see how the turtorial could actually work anyway.

Any ideas? Is this tute just outdated and using some redundant stuff?

Cheers
Aaron


Messages In This Thread
Blog Video Tutorial - Is it still possible to complete? - by El Forum - 08-21-2008, 09:47 PM
Blog Video Tutorial - Is it still possible to complete? - by El Forum - 08-25-2008, 08:15 AM
Blog Video Tutorial - Is it still possible to complete? - by El Forum - 08-25-2008, 09:30 AM
Blog Video Tutorial - Is it still possible to complete? - by El Forum - 08-26-2008, 04:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB