Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Element's Avatar
    Join Date
    Jul 2004
    Location
    Lynnwood, Washington, US
    Posts
    855
    Thanks
    2
    Thanked 2 Times in 2 Posts

    PHP MySQL and Header Redirection Problem! (Please Help)

    Well the error with this, is the header("Location: ".$url); doesn't work, and even when I use a Javascript version it still doesn't work. I think it might have to do witht he enclosing PHP. Please help me. Here is the code that has the error.

    PHP Code:
    <?php

                 $username 
    "****";
                 
    $password "****";
                 
    $database "****";

        if (
    $_GET['go'] !== "") {

             
    mysql_connect(localhost,$username,$password);
             @
    mysql_select_db($database) or die( "Unable to select database");
             
    $query="SELECT * FROM go WHERE id='$go'";
             
    $result=mysql_query($query);

             
    $num=mysql_num_rows($result);

             
    mysql_close();

            
    $i=0;
            while (
    $i $num) {

             
    $url=mysql_result($result,$i,"url");

             echo 
    '<script language="JavaScript">'//Testing JavaScript
             
    echo '<!--';
             echo 
    'window.location="'.$url.'"';
             echo 
    '//-->';
             echo 
    '</script>';


             
    $header header("Location: ".$url); // Not testing anymore


            
    $i++;
            }

        }
        else {

    ?>

  • #2
    New Coder
    Join Date
    Jul 2005
    Location
    Perth, Australia. Age: 13
    Posts
    81
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Take away the $header =
    I lost my signature, have you seen it?
    I have the power to erase you...

  • #3
    Regular Coder
    Join Date
    Jan 2005
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also, header MUST be called before ANY data is outputted on the screen (before any echo's, print's, ect.)


  •  

    Posting Permissions

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