Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8689069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:32:40+00:00 2026-06-12T23:32:40+00:00

Have copy pasted the code from Blog tutorial in cakephp 2.2 but its not

  • 0

Have copy pasted the code from Blog tutorial in cakephp 2.2 but its not working.
Getting the following errors.
Notice (8): Use of undefined constant Html
Notice (8): Use of undefined constant Form
Notice (8): Use of undefined constant posts
Notice (8): Use of undefined constant all Notice (8): Undefined index: all
Below is the code for PostsController and index.ctp.

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

index.ctp
 <h1>Blog posts</h1>
 <table>
 <tr>
 <th>Id</th>
 <th>Title</th>
 <th>Created</th>
 </tr>
 <?php foreach ($posts as $post): ?>
 <tr>
 <td><?php echo $post[’Post’][’id’]; ?></td>
 <td>
 <?php echo $post[’Post’][’title’]; ?>
 </td>
 <td><?php echo $post[’Post’][’created’]; ?></td>
 </tr>
 <?php endforeach; ?>
 <?php unset($post); ?>
 </table>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:32:42+00:00Added an answer on June 12, 2026 at 11:32 pm

    dont use ’ as they are not php syntax (used only in mysql)

    use ‘ instead (simple apostrophe):

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

    furthermore <?php unset($post); ?> is unnecessary, you should escape your output echo h($post[’Post’][’title’]) and you should omit the closing tag ?> in your php files (not in the view files, though)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have such code (copy paste from wiki). Its multiplication of those big numbers
I have a page with multiple tabs. But if you copy/paste the code and
Ok just to know,I copy-pasted the code from the android website,so I don't think
I have a code file from the boto framework pasted below, all of the
I have an AdSense account, and simply copy/pasted a block of Javascript to include
I have a class which does not have copy constructor or operator= overloaded. The
When I try to copy code from eclipse and paste it in the actionscript
I'm trying to post some code snippets on my WordPress blog, but when I
i tried to do tutorial from http://developer.android.com/resources/tutorials/opengl/opengl-es20.html But what I wanted was to create
I have a working python wrapper for C++ code (as suggested here Calling C/C++

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.