1
votes

Im just starting out with php and cakePhp in general. I encountered the following error while trying to implement the blog tutorial.
I have followed the steps in the tutorial till here http://book.cakephp.org/2.0/en/getting-started.html#creating-post-views

Screenshots of the error msgs are here-
[1]: http://i.imgur.com/xLvz3.png "top"
[2]: http://i.imgur.com/cJHPK.png "bottom"

Model/Post.php

    <?php        
   class Post extends AppModel {}

Controller/PostsController.php

    <?php
class PostsController extends AppController {
public $helpers = array(’Html’, ’Form’);

public function index() {
    $this->set(’posts’, $this->Post->find(’all’));
}

public function view($id = null) {
    $this->Post->id = $id;
    $this->set(’post’, $this->Post->read());
}}

Posts/index.ctp

     <h1>Blog posts</h1>
     <table>
<tr>
    <th>Id</th>
    <th>Title</th>
    <th>Created</th>
</tr>

<!-- Here is where we loop through our $posts array, printing out post info -->

<?php foreach ($posts as $post): ?>
<tr>
    <td><?php echo $post['Post']['id']; ?></td>
    <td>
        <?php echo $this->Html->link($post['Post']['title'],
     array('controller' => 'posts', 'action' => 'view', $post['Post']['id'])); ?>
    </td>
    <td><?php echo $post['Post']['created']; ?></td>
</tr>
<?php endforeach; ?>
<?php unset($post); ?>

1
@Ross added code from files. - asloob
check my answer for the first problem. For the second, it must be resolved by the change that i post in my answer - Anas

1 Answers

3
votes

Replace " ’ " by a simple quote " ' ".

so you must declare helpers as :

      public $helpers = array('Html', 'Form');

the same change for find method param :

      $this->set('posts', $this->Post->find('all'));

at last

      $this->set('post', $this->Post->read());

Anas