PostNuke: A Flexible Open Source Content Management System
home | forum | international support | contact us

Support Forum

Start ::  Developers Corner ::  Module Development ::  pnRedirect failing

Moderated by: Support Team

Goto page : 1 | 2 Next Page
Bottom
pnRedirect failing

  • Link to this postingPosted: 25.02.2006, 20:52
    Profile
    Paustian
    rank:
    pnHelper pnHelper
    registered:
     May 2005
    Status:
    offline
    last visit:
    23.04.08
    Posts:
    105
    I have run into something really strange. pnRedirect is failing to redirect and instead is giving me a blank white page. Here is some example code that fails in the module.

    Code
    function Exams_admin_test()
    {
        pnRedirect(pnModURL('Exams', 'admin', 'viewitems'));
        return true;
    }


    Redirects will work in other modules, but not in this one. Any ideas?
  • Link to this postingPosted: 25.02.2006, 21:09
    Profile
    Topiatic
    rank:
    pnProfessional pnProfessional
    registered:
     November 2003
    Status:
    offline
    last visit:
    09.05.08
    Posts:
    1530
    Try
    Code
    return pnRedirect(pnModURL('Exams', 'admin', 'viewitems'));

    -----
    viewTopiaryWorks($twWorks, $twRosterMaster)
  • Link to this postingPosted: 25.02.2006, 22:40
    Profile
    Hunkpapa
    rank:
    pnFreshman pnFreshman
    registered:
     January 2006
    Status:
    offline
    last visit:
    30.03.06
    Posts:
    18
    I had the same problem earlier.. another problem can be that the headers are already sent

    Code
    if (headers_sent()) {
        echo 'headers are already sent';
    } else {
        return pnRedirect(pnModURL('Exams', 'admin', 'viewitems'));
    }

    Headers will be sent if you for example echo something (http://www.php.net/headers_sent)
  • Link to this postingPosted: 26.02.2006, 03:54
    Profile
    Paustian
    rank:
    pnHelper pnHelper
    registered:
     May 2005
    Status:
    offline
    last visit:
    23.04.08
    Posts:
    105
    Yep, that is it. Headers are being sent. Thanks Hunkpapa, now I have to figure out what is writing text out. I have some require_once statements in my code, and from reading other posts, that maybe a problem.
  • Link to this postingPosted: 26.02.2006, 04:25
    Profile
    Paustian
    rank:
    pnHelper pnHelper
    registered:
     May 2005
    Status:
    offline
    last visit:
    23.04.08
    Posts:
    105
    I'm stumped. I completely deleted the file this code was in, pnAdmin.php and added the following as the file

    Code
    <?php
    function Exams_admin_test()
    {
        if (headers_sent()) {
                echo 'headers are already sent';
        } else {
                pnRedirect(pnModURL('Exams', 'admin', 'viewitems'));
                return true;
        }
        //return pnRedirect(pnModURL('Exams', 'admin', 'viewitems'));
    }
    ?>


    When I try to load the function using the following URL

    http://localhost/microtextbook/index.php?module=Exams&type=admin&func=test

    I get the message,

    headers are already sent.

    Any ideas?
  • Link to this postingPosted: 26.02.2006, 04:36
    Profile Homepage
    AbraCadaver
    rank:
    pnProfessional pnProfessional
    registered:
     August 2002
    Status:
    offline
    last visit:
    21.04.08
    Posts:
    1382
    Do you maybe have a space or carriage return before the opening
  • Link to this postingPosted: 26.02.2006, 08:41
    Profile Homepage
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    09.05.08
    Posts:
    13324
    Only a few topics down from this one we've already been through all the reasons for pnRedirect failing icon_wink

    http://forums.postnuke.co...file=viewtopic&t=47031

    -----
    Regards,
    Simon

    itbegins.co.uk - PostNuke Consulting

    Please read the Support Guide
  • Link to this postingPosted: 26.02.2006, 19:21
    Profile
    Paustian
    rank:
    pnHelper pnHelper
    registered:
     May 2005
    Status:
    offline
    last visit:
    23.04.08
    Posts:
    105
    Hammerhead,

    Thanks. I had already seen that thread, but none of the suggestions helped. Anyhow, I was alble to solve the problem by reading up a bit on headers_sent(). It turns out there are two optional parameters that are very useful for tracking down this sort of problem. Here is the code I used

    Code
    function Exams_admin_test()
    {
        if (headers_sent($filename, $linename)) {
                echo "headers are already sent in $filename at $linename";
        } else {
                pnRedirect(pnModURL('Exams', 'admin', 'viewitems'));
                return true;
        }
    }


    This pointed to my pnTables.php file. I had some extra return characters after the closing ?> at the end of the file. Elimination of these fixed the problem.

    Thanks to everyone who helped on this. BTW, Andreas and I are almost finished with a major upgrade of the Exams module.
  • Link to this postingPosted: 26.02.2006, 19:56
    Profile Homepage
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    09.05.08
    Posts:
    13324
    Glad you found the problem

    -----
    Regards,
    Simon

    itbegins.co.uk - PostNuke Consulting

    Please read the Support Guide
  • Link to this postingPosted: 26.02.2006, 22:07
    Profile Homepage
    AbraCadaver
    rank:
    pnProfessional pnProfessional
    registered:
     August 2002
    Status:
    offline
    last visit:
    21.04.08
    Posts:
    1382
    [quote=AbraCadaver]Do you maybe have a space or carriage return before the opening
  • Link to this postingPosted: 26.02.2006, 22:21
    Profile Homepage
    AmmoDump
    rank:
    pnProfessional pnProfessional
    registered:
     December 2003
    Status:
    offline
    last visit:
    08.05.08
    Posts:
    2635
    Whats the deal with the carriage returns... how do they affect the interpreter??

    -----
    -- David Pahl -- (PostNuke Support Team)

    <div id="me" class="none" style="none" />

  • Link to this postingPosted: 26.02.2006, 22:41
    Profile Homepage
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    09.05.08
    Posts:
    13324
    Anything outside of PHP tags is treated as HTML source code, and therefore is sent to the browser (even if it is just empty line returns). You can't send headers to the browser if you've already sent it HTML content, so blank lines at the end of files cause the header function to fail.

    -----
    Regards,
    Simon

    itbegins.co.uk - PostNuke Consulting

    Please read the Support Guide
  • Link to this postingPosted: 26.02.2006, 23:56
    Profile Homepage
    AmmoDump
    rank:
    pnProfessional pnProfessional
    registered:
     December 2003
    Status:
    offline
    last visit:
    08.05.08
    Posts:
    2635
    Really, even though the the file has a .php extension... it defualts to HTML outside the PHP tags... interestng... I did not know that...

    /me rethinks problems from the past.

    /me learns something today...

    /me thought I was just partying with the wife today....

    -----
    -- David Pahl -- (PostNuke Support Team)

    <div id="me" class="none" style="none" />

  • Link to this postingPosted: 26.02.2006, 23:58
    Profile Homepage
    AmmoDump
    rank:
    pnProfessional pnProfessional
    registered:
     December 2003
    Status:
    offline
    last visit:
    08.05.08
    Posts:
    2635
    ...but carriage returns have no purpose outside the
     tag...??

    /me still wonders...

    -----
    -- David Pahl -- (PostNuke Support Team)

    <div id="me" class="none" style="none" />

  • Link to this postingPosted: 27.02.2006, 08:24
    Profile Homepage
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    09.05.08
    Posts:
    13324
    The PHP parser is always in HTML mode until it his a
Goto page : 1 | 2 Next Page

Start ::  Developers Corner ::  Module Development ::  pnRedirect failing

Main Menu

Extensions Database

Documentation

Development

Login





 


 Log in Problems?
 New User? Sign Up!

Donate to PostNuke