Looks like your link is wrong. It should be something like this:
<code>
echo $this->Html->link('Edit', array('controller' => 'posts', 'action' =>
'view', $post['id']));
</code>
Check that (i) you have got the 'action' piece of the link (else it will
default to 'index', which might be where you are going wrong) and (ii) that I
have guessed the $post['id'] piece right - yours looks OK.
Jeremy Burns
[email protected]
On 11 Apr 2010, at 12:33, Edward wrote:
> Hi,
> I've been working on the blog tutorial.
> I'm using XAMPP on windows. I'm also using CentOS as well.
> Anyhow, I have a folder called 'cakephp' and unzipped the 1.2.6 stable
> version.
> I encountered a problem at 10.1.8 Creating Post Views.
> I made index.ctp page and it shows 3 items stored on the database
> fine.
> (URL used to access is http://localhost:8181/cakephp/posts/index)
> But when I click on one of the links, I get a with no data.
> I believe this is a problem with URL but I don't know how to fix it.
> URL used to access individual item is
> http://localhost:8181/cakephp/posts/view/index/1
> At the bottom of the page it says
> SELECT `Post`.`id`, `Post`.`title`, `Post`.`body`, `Post`.`created`,
> `Post`.`modified` FROM `posts` AS `Post` WHERE `Post`.`id` = 'index'
> LIMIT 1
> So obviously, it's not taking '1' but 'index' as an incoming value for
> the function view in PostsController.
> Here's the posts_controller.php
> <?php
> class PostsController extends AppController {
> var $name = 'Posts';
>
> function index(){
> $this->set('posts', $this->Post->find('all'));
> }
>
> function view($id = null){
> $this->Post->id = $id;
> $this->set('post', $this->Post->read());
> }
>
> function add(){
> if(!empty($this->data)){
> if($this->Post->save($this->data)){
> $this->Session->setFlash('Your post has been saved.');
> $this->redirect(array('action'=> 'index'));
> }
> }
> }
> }
> ?>
>
> Can anyone please give me a suggestion as to what I can do to fix this
> problem?
> Thanks for your help in advance.
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>
> To unsubscribe, reply using "remove me" as the subject.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en