Redirect - redirects to blank page

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Redirect - redirects to blank page

Syl-2

Hey all !!

So, I've hit my head against a wall for the last several hours, and
done all the searches I can think of.....and, I just cannot think of
any other way of tackling this problem.

I've created a view/controller that do not have a model.  Based on a a
choice the user makes, the controller saves to one of  three other
models.

Here is my controller code :
=============================================================
        function newkeyword() {
                if (empty ($this->data)) {
                        $this->render();
                } else {
                        $this->cleanUpFields();
                        $type = $this->data['Keyword']['Type'];
                        $mdlName = null;
                        switch ($type) {
                                case "help" :
                                        $mdlName = 'HelpCategory';
                                        break;
                                case "cat" :
                                        $mdlName = 'Category';
                                        break;
                                case "sub" :
                                        $mdlName = 'SubCategory';
                                        break;

                        }

                        $saveData[$mdlName]['frText'] =  $this->data['Keyword']['frText'];
                        $saveData[$mdlName]['engText'] =  $this->data['Keyword']['engText'];

                        if ($this->$mdlName->save($saveData)) {
                                debug('SAVED');
                                $this->redirect('/keywords/keywordlist');
                                debug('AFTER Redirect');
                        } else {
                                debug('ERROR');
                                $this->Session->setFlash('Please correct errors below.');
                        }
                }
        }
=============================================================
The debug statements and looking at the DB shows that the save has
occurred successfully.  But, rather than re-direct-ing to the
keywordslist page, the same page is reloaded (namely,
keywords/newkeyword).

What am I missing ?  It seems to make perfect sense to me that this
should work.

Thanks all !

Syl


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Redirect - redirects to blank page

cadraig

Code looks alright to my (very) untrained eye.  Clutching at straws
here...

What does your routes.php look like...  I expect you've checked that
though.
Are you declaring the models in your uses var at the top of the
controller?
Also have you got anything weird going on with the validation in your
models?

sorry couldn't help much more.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Redirect - redirects to blank page

Syl-2

Hey Time - Thanks for your reply :-).  Clutching at straws is better
than clutching at air .... :p

Hmmm....I haven't messed around with routes.php, I don't quite get it
yet.  But, I am hoping that because all my other redirects are
working....this one should too ?

Yep, I'm declaring the models at the top of the controller.

Nothing weird with the validation.  I just copied and renamed my code
from one of the views.

S


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Redirect - redirects to blank page

Syl-3

Anyone have any ideas ?  I'm willing to try just about anything right
now.

S


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Redirect - redirects to blank page

Syl-2
In reply to this post by Syl-2

Anyone have any ideas ?  I'm willing to try just about anything right
now.

S

On Oct 31, 5:04 pm, "Syl" <[hidden email]> wrote:

> Hey Time - Thanks for your reply :-).  Clutching at straws is better
> than clutching at air .... :p
>
> Hmmm....I haven't messed around with routes.php, I don't quite get it
> yet.  But, I am hoping that because all my other redirects are
> working....this one should too ?
>
> Yep, I'm declaring the models at the top of the controller.
>
> Nothing weird with the validation.  I just copied and renamed my code
> from one of the views.
>
> S


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Redirect - redirects to blank page

Meek-2

you say you get a blank page - completely blank? Or do you see
anything? what is DEBUG set to in config/core.php?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Redirect - redirects to blank page

Syl-2

Unfortunately yes....completely blank, not even a layout (DEBUG set to
0).  View source shows nothing.
If DEBUG is set to 2....I get the debug messages from my code,
indicating that my data has been saved.

I also added debug code to the redirect to see what was going on.  The
redirect Location correctly points to /keywords/keywordlist.  But,
somehow, the URL in my browser does not display that, it displays
/keywords/newkeyword.

S

On Nov 1, 10:19 am, "meek" <[hidden email]> wrote:
> you say you get a blank page - completely blank? Or do you see
> anything? what is DEBUG set to in config/core.php?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Redirect - redirects to blank page

Meek-2

Well I'm not surely what exactly is going on but I did have a similar
problem the other day.
First of all I would recommend keeping DEBUG set to 2 until you've got
rid of the issue - at least then if there's an error message you'll see
it.
My problem was simply some extra whitespace before the <?php tag in my
controller. The redirect function uses the PHP header function which
must be called before ANYTHING is sent to the browser. Extra whitespace
outwith PHP tags in your controller, or in any other file being
included will prevent the redirect. This a common reason for redirects
not working.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Redirect - redirects to blank page

Syl-2

Wow !  Thanks was it.....I knew I'd be kicking myself for how simple a
solution it would be.  I will definately keep it in mind.

Just as a side note :  When I have DEBUG set to 2, sometimes my
redirects don't work as well, so I have to reset it to 0 each time to
make sure that it wasn't the DEBUG that was causing me the problem.

S

On Nov 1, 10:58 am, "meek" <[hidden email]> wrote:

> Well I'm not surely what exactly is going on but I did have a similar
> problem the other day.
> First of all I would recommend keeping DEBUG set to 2 until you've got
> rid of the issue - at least then if there's an error message you'll see
> it.
> My problem was simply some extra whitespace before the <?php tag in my
> controller. The redirect function uses the PHP header function which
> must be called before ANYTHING is sent to the browser. Extra whitespace
> outwith PHP tags in your controller, or in any other file being
> included will prevent the redirect. This a common reason for redirects
> not working.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Re: Redirect - redirects to blank page

Samuel DeVore

One thing to keep an eye out for is some text editors have a "Freehand
Editing" mode (TextMate for one) and sometimes inadvertent mouse
clicks can add extra spaces after closing tags.  You might keep an eye
out for a setting like that, I try not to use that editing mode for
that reason.  Also some ide/code editors have a setting to remove
trailing white space, this can be a helpful setting.

I tend to only use debug setting of 2 when I am having issues with
queries, otherwise I develop in debug 1 (just shows warnings and
notices not sql queries)  I have not seen issues with redirects if my
warnings and notices are taken care of.  If you are it could mean that
you have other issues still haunting you (it is close to halloween
after all)

Sam D

On 11/1/06, Syl <[hidden email]> wrote:

>
> Wow !  Thanks was it.....I knew I'd be kicking myself for how simple a
> solution it would be.  I will definately keep it in mind.
>
> Just as a side note :  When I have DEBUG set to 2, sometimes my
> redirects don't work as well, so I have to reset it to 0 each time to
> make sure that it wasn't the DEBUG that was causing me the problem.
>
> S
>
> On Nov 1, 10:58 am, "meek" <[hidden email]> wrote:
> > Well I'm not surely what exactly is going on but I did have a similar
> > problem the other day.
> > First of all I would recommend keeping DEBUG set to 2 until you've got
> > rid of the issue - at least then if there's an error message you'll see
> > it.
> > My problem was simply some extra whitespace before the <?php tag in my
> > controller. The redirect function uses the PHP header function which
> > must be called before ANYTHING is sent to the browser. Extra whitespace
> > outwith PHP tags in your controller, or in any other file being
> > included will prevent the redirect. This a common reason for redirects
> > not working.
>
>
> >
>


--
==
S. DeVore
(the old fart) the advice is free, the lack of crankiness will cost you

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---