Results 1 to 7 of 7

Thread: -[RESOLVED]- Header. Give me response.redirect anyday.. Can you turn me back?

Hybrid View

  1. #1
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Header crap. Give me response.redirect anyday.. Can you turn me back?

    I'm going to takle your questions in reverse.
    First why the cannot send headers info: 1) Make sure there is NOT BLANK lines or anything at the top. Even a single whitespace is considered output. Secondly, the error generated by line resulted in output (the error msg). So Once you get that straightended out, it should go away.

    Ok, now for the error on line 2. You really should check to see if the $_GET[] is set first:

    Code:
     if (isset($_GET["action"])) {
    $Action = $_GET["action"];
    }else{$Action='';}
    Then use $Action in your switch:
    Code:
    switch ($Action) {
           case "auth":
    	   
    	        echo "you are at auth";
           
    	   break;
    	   
           case "sum": 
    	   
    	   	   echo "you are at sum";
           
    	   break;
    	   
           case "phpinfo": 
    	   
    	   	   phpinfo();
    	   
           break;
           default: 
    	   	   header( 'location:http://localhost:1987/php_dev/index.php?action=auth' );
    	   exit;
       }
    ?>

    To attempt to access it w/o first making sure it's there is akin to acessing an object before instanciating it.


    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  2. #2

    Thread Starter
    Addicted Member DigitalMyth's Avatar
    Join Date
    Nov 2002
    Location
    England..
    Posts
    169

    Re: Header crap. Give me response.redirect anyday.. Can you turn me back?

    ok, you may of pulled me back to PHP.

    One question is;

    is there a redirect command that can me used at any point?

    The Response.Redirect command is useable at anytime. Is there one for PHP

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Header crap. Give me response.redirect anyday.. Can you turn me back?

    Quote Originally Posted by DigitalMyth
    ok, you may of pulled me back to PHP.

    One question is;

    is there a redirect command that can me used at any point?

    The Response.Redirect command is useable at anytime. Is there one for PHP
    Yes and no. Firstly it is best to have a redirect at the top of your script before any output as it makes the code more readable to other developers.

    Should the need still arise to send a header after output has been sent you can use output buffering. An output buffer is a place where all output from the script is held until the script is done executing. Once the script has finished the buffer is flushed and all the data is sent to the client in one big chunk.

    To turn on the ouput buffer just add this as the top line of your script:
    PHP Code:
    <?php
        ob_start
    ();
    ?>
    You can do some pretty neat things with output buffers, such as nesting and compression so it is also worth looking at the other functions which relate to ouput buffering.

    http://uk.php.net/manual/en/ref.outcontrol.php
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Header crap. Give me response.redirect anyday.. Can you turn me back?

    There WAS output before the redirect: the notice that was generated by accessing a non-existent array element.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Header crap. Give me response.redirect anyday.. Can you turn me back?

    Quote Originally Posted by CornedBee
    There WAS output before the redirect: the notice that was generated by accessing a non-existent array element.
    Isn't that what I said?

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Header. Give me response.redirect anyday.. Can you turn me back?

    Yes, but the problem is so common that your mention was not prominent enough.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width