On Thursday, October 16, 2008 6:05:54 PM UTC+7, Marcus Silva wrote:
Try removing any hidden character you may have after the php closing--
tag (?>).
Example:
?>remove anything after the tag....
Hope it helps
Cheers
Marcus
On Oct 16, 11:31 am, imu <imranfastm...@gmail.com> wrote:
> ------------------------------------------------------------ ------------------------------ --------------------------
>
> controller file is messages_controller.php
>
> ------------------------------------------------------------ ------------------------------ --------------------------
> <?php
> class MessagesController extends AppController{
> var $name = 'Messages';
>
> var $helpers = array (
> 'Html',
> 'Form',
> 'Time'
> );
>
> function index($id = null ){
> if (!$id) {
> $this->Session->setFlash('Invalid Topic');
> $this->redirect(array (
> 'action' => 'index'
> ), null, true);
> }
> $this->Message->recursive = 1;
>
> $messages = $this->Message->find('all',
> array( 'conditions' => array( 'topic_id' => $id ),'order' =>
> 'Message.id DESC') );
> $this->set('topic_id',$id);
> $this->set('messages',$messages);
> }
>
> function add($id = null) {
> if (!empty ($this->data)) {
> $this->Message->create();
> if ($this->Message->save($this->data)) {
>
> $this->Session->setFlash('The message has been
> added');
> $this->redirect(array (
> 'action' => 'index'
> ), null, true);
> } else {
> $this->Session->setFlash('message posting
> failed. Try again.');
> }
> }
> $users = $this->Message->User->find('list');
> $this->set('topic_id',$id);
> $this->set('users',$users);
> }
>
> }
> ?>
>
> ------------------------------------------------------------ ------------------------------ ------------------------------ ---------
>
> My view file is messages folders in views as add.ctp
>
> ------------------------------------------------------------ ------------------------------ ------------------------------ ---------
>
> <?php echo $form->create('Message',array( 'url' => 'add/'.
> $topic_id ));?>
> <fieldset>
> <legend>New topic</legend>
> <?php
> echo $form->input('message_text');
> echo $form->input('user_id');
> echo $form->hidden('topic_id',array( 'value' => $topic_id));
> ?>
> </fieldset>
> <?php echo $form->end('post a message');?>
>
> <?php
> echo $html->link('Go back', array('action'=>'index'));
> ?>
>
> ------------------------------------------------------------ ------------------------------ ------------------------------ ---------
>
> When I fill up the add form and submit.
> The data gets inserted into the messages table without any hiccups.
>
> But I get an error during redirection back to the index page like this
>
> ------------------------------------------------------------ ------------------------------ ------------------
>
> Warning (2): Cannot modify header information - headers already sent
> by (output started at /opt/lampp/htdocs/cake/message_board/app/
> controllers/messages_controller.php:115) [CORE/cake/libs/controller/
> controller.php, line 587]
>
> Code | Context
>
> $status = "Location:http://localhost/cake/message_board/messages "
>
> header - [internal], line ??
> Controller::header() - CORE/cake/libs/controller/controller.php, line
> 587
> Controller::redirect() - CORE/cake/libs/controller/controller.php,
> line 568
> MessagesController::add() - APP/controllers/messages_controller.php,
> line 54
> Object::dispatchMethod() - CORE/cake/libs/object.php, line 116
> Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 259
> Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 213
> [main] - APP/webroot/index.php, line 90
>
> ------------------------------------------------------------ ------------------------------ ---------------------
> The redirection to the index page fails.
>
> The parameters supplied in the form in add.ctp was as I expected
> "messages/add/1" which you can see the below code
> ------------------------------------------------------------ ------------------------------ ---------------------
> <form method="post" action="/cake/message_board/messages/add/
> 1"><fieldset style="display:none;"><input type="hidden" name="_method"
> value="POST" /></fieldset> <fieldset>
> <legend>New topic</legend>
> ------------------------------------------------------------ ------------------------------ ---------------------
>
> Please, help me out with this problem??
>
> Thank you
>
> Imranullah Mohammed
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment