Bug or not bug

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • paullefil

    Bug or not bug

    I have 3 files on my website

    tes1.php :
    <?php
    require_once("t est2.php");

    if ($_GET['redirige'] == 1)
    {
    @header( "Location: http://www.mydomain.co m/test3.php" );
    }
    else
    {
    echo "it's test1.php";
    }
    ?>

    and test2.php (one file without php code !)

    <?php
    ?>

    and test3.php :

    <?php
    print "it's test3.php";
    ?>

    Now if you load :

    (it's written "it's test1.php")

    Now if you load :


    The result is a blank page but normally you will be redirect to
    http://www.mydomain.com/test3.php with "it's test3.php" written.

    Now in the test1.php file, you delete the ligne
    require_once("t est2.php");
    So your test1.php file is :

    <?php
    if ($_GET['redirige'] == 1)
    {
    @header( "Location: http://www.mydomain.co m/test3.php" );
    }
    else
    {
    echo "on affiche test1.php";
    }
    ?>

    Now if you load :

    (it's written "it's test1.php")

    Now if you load :


    The result is a OK you are redirect to
    http://www.mydomain.com/test3.php with "it's test3.phpp" written.

    Could you help me, where is the bug ?

    SBE

  • Rik

    #2
    Re: Bug or not bug

    paullefil wrote:
    I have 3 files on my website
    >
    tes1.php :
    <?php
    require_once("t est2.php");
    >
    if ($_GET['redirige'] == 1)
    {
    @header( "Location: http://www.mydomain.co m/test3.php" );
    }
    else
    {
    echo "it's test1.php";
    }
    >>
    >
    and test2.php (one file without php code !)
    >
    <?php
    >>
    >
    and test3.php :
    >
    <?php
    print "it's test3.php";
    >>
    >
    Now if you load :

    (it's written "it's test1.php")
    >
    Now if you load :

    >
    The result is a blank page but normally you will be redirect to
    http://www.mydomain.com/test3.php with "it's test3.php" written.
    >
    Now in the test1.php file, you delete the ligne
    require_once("t est2.php");
    So your test1.php file is :
    >
    <?php
    if ($_GET['redirige'] == 1)
    {
    @header( "Location: http://www.mydomain.co m/test3.php" );
    }
    else
    {
    echo "on affiche test1.php";
    }
    >>
    >
    Now if you load :

    (it's written "it's test1.php")
    >
    Now if you load :

    >
    The result is a OK you are redirect to
    http://www.mydomain.com/test3.php with "it's test3.phpp" written.
    >
    Could you help me, where is the bug ?
    Probably a space/newline/something outside <?php ?in test2.php.
    Try this in test1.php:
    ini_set('displa y_errors',1);
    error_reporting (E_ALL);

    Which will probably tell you headers are already sent by test2.php

    Grtz,
    --
    Rik Wasmus


    Comment

    • Jerry Stuckle

      #3
      Re: Bug or not bug

      paullefil wrote:
      I have 3 files on my website
      >
      tes1.php :
      <?php
      require_once("t est2.php");
      >
      if ($_GET['redirige'] == 1)
      {
      @header( "Location: http://www.mydomain.co m/test3.php" );
      }
      else
      {
      echo "it's test1.php";
      }
      ?>
      >
      and test2.php (one file without php code !)
      >
      <?php
      ?>
      >
      and test3.php :
      >
      <?php
      print "it's test3.php";
      ?>
      >
      Now if you load :

      (it's written "it's test1.php")
      >
      Now if you load :

      >
      The result is a blank page but normally you will be redirect to
      http://www.mydomain.com/test3.php with "it's test3.php" written.
      >
      Now in the test1.php file, you delete the ligne
      require_once("t est2.php");
      So your test1.php file is :
      >
      <?php
      if ($_GET['redirige'] == 1)
      {
      @header( "Location: http://www.mydomain.co m/test3.php" );
      }
      else
      {
      echo "on affiche test1.php";
      }
      ?>
      >
      Now if you load :

      (it's written "it's test1.php")
      >
      Now if you load :

      >
      The result is a OK you are redirect to
      http://www.mydomain.com/test3.php with "it's test3.phpp" written.
      >
      Could you help me, where is the bug ?
      >
      SBE
      >
      You've got white space before or after your php code in test2.php.

      If you were displaying errors, you'd get a message about the headers
      already being sent due to this white space.

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Alvaro G. Vicario

        #4
        Re: Bug or not bug

        *** paullefil escribió/wrote (25 Aug 2006 09:39:21 -0700):
        @header( "Location: http://www.mydomain.co m/test3.php" );
        The @ operator removes any possible warning or error message. You'll never
        be able to debug properly if you drop it here and there in your code.
        Furthermore, what runtime error are you expecting in a call to header()??

        Also, sending a header doesn't stop the script execution. I suggest you
        append an exit() statement.
        The result is a blank page but normally you will be redirect to
        http://www.mydomain.com/test3.php with "it's test3.php" written.
        Have you enabled error reporting directives in "php.ini". If I recall
        correctly, they are:

        display_errors = On
        error_reporting = E_ALL


        --
        -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
        ++ Mi sitio sobre programación web: http://bits.demogracia.com
        +- Mi web de humor con rayos UVA: http://www.demogracia.com
        --

        Comment

        • paullefil

          #5
          Re: Bug or not bug

          Thank you very much !
          It was a space after ?in the file test2.php


          Alvaro G. Vicario a écrit :
          *** paullefil escribió/wrote (25 Aug 2006 09:39:21 -0700):
          @header( "Location: http://www.mydomain.co m/test3.php" );
          >
          The @ operator removes any possible warning or error message. You'll never
          be able to debug properly if you drop it here and there in your code.
          Furthermore, what runtime error are you expecting in a call to header()??
          >
          Also, sending a header doesn't stop the script execution. I suggest you
          append an exit() statement.
          >
          The result is a blank page but normally you will be redirect to
          http://www.mydomain.com/test3.php with "it's test3.php" written.
          >
          Have you enabled error reporting directives in "php.ini". If I recall
          correctly, they are:
          >
          display_errors = On
          error_reporting = E_ALL
          >
          >
          --
          -+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
          ++ Mi sitio sobre programación web: http://bits.demogracia.com
          +- Mi web de humor con rayos UVA: http://www.demogracia.com
          --

          Comment

          Working...