error-logs() bug ??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yaaros@gmail.com

    error-logs() bug ??

    Hello !! I have a problem with error_logs. The problem is in this
    code:

    $id_tmp = $_REQUEST["id"];
    if(!isset($id_t mp) && empty($id_tmp)) {
    invalidArgs();
    echo "buug";
    }

    I'd like to check if the variable id is passed by GET method to the
    script. If not, function invalidArgs() will start.
    In function invalidArgs() I thrown exception InvalidArgsExce ption. I
    set a handler for whole script to manage exceptions using
    set_exception_h andler(); function. I write, by error_log, errors to
    file and show warning page that the parameter id isn't pass through.

    And the problem is that when I open this page in www browser IE6 and
    put correct parameter id everything is ok, the page that suppose to is
    showing but in file where errors are written (by error_logs), are
    appeared errors of InvalidArgsExce ption ?? That's really weird
    because the script doesn't suppose to get into if-block and start
    function invalidArgs(). What is wrong, why error_log writes an errors
    that doesn't suppose to ?? Everything work correct, the page and the
    rest of the script acts like it gets the id parameter from GET
    methods, but there is entry in error_log file ??

  • Willem Bogaerts

    #2
    Re: error-logs() bug ??

    $id_tmp = $_REQUEST["id"];

    This fails if there is no index "id", that is, if there is no id field sent.
    if(!isset($id_t mp) && empty($id_tmp)) {
    invalidArgs();
    echo "buug";
    }
    This part will not be reached, because the code fails before this block.
    ..., the page that suppose to is
    showing but in file where errors are written (by error_logs), are
    appeared errors of InvalidArgsExce ption ?? That's really weird
    because the script doesn't suppose to get into if-block and start
    function invalidArgs().
    Best regards,
    --
    Willem Bogaerts

    Application smith
    Kratz B.V.

    Comment

    • Captain Paralytic

      #3
      Re: error-logs() bug ??

      On 26 Jun, 15:13, yaa...@gmail.co m wrote:
      Hello !! I have a problem with error_logs. The problem is in this
      code:
      >
      $id_tmp = $_REQUEST["id"];
      if(!isset($id_t mp) && empty($id_tmp)) {
      invalidArgs();
      echo "buug";
      >
      }
      >
      I'd like to check if the variable id is passed by GET method to the
      script. If not, function invalidArgs() will start.
      In function invalidArgs() I thrown exception InvalidArgsExce ption. I
      set a handler for whole script to manage exceptions using
      set_exception_h andler(); function. I write, by error_log, errors to
      file and show warning page that the parameter id isn't pass through.
      >
      And the problem is that when I open this page in www browser IE6 and
      put correct parameter id everything is ok, the page that suppose to is
      showing but in file where errors are written (by error_logs), are
      appeared errors of InvalidArgsExce ption ?? That's really weird
      because the script doesn't suppose to get into if-block and start
      function invalidArgs(). What is wrong, why error_log writes an errors
      that doesn't suppose to ?? Everything work correct, the page and the
      rest of the script acts like it gets the id parameter from GET
      methods, but there is entry in error_log file ??
      Try

      if(!isset($_REQ UEST["id"]) || empty($_REQUEST["id"])){
      invalidArgs();
      echo "buug";
      }

      Comment

      • yaaros@gmail.com

        #4
        Re: error-logs() bug ??

        On 26 Cze, 16:16, Willem Bogaerts
        <w.bogae...@kra tz.maardanzonde rditstuk.nlwrot e:
        $id_tmp = $_REQUEST["id"];
        >
        This fails if there is no index "id", that is, if there is no id field sent.
        >
        if(!isset($id_t mp) && empty($id_tmp)) {
        invalidArgs();
        echo "buug";
        }
        >
        This part will not be reached, because the code fails before this block.
        >
        ..., the page that suppose to is
        showing but in file where errors are written (by error_logs), are
        appeared errors of InvalidArgsExce ption ?? That's really weird
        because the script doesn't suppose to get into if-block and start
        function invalidArgs().
        >
        Best regards,
        --
        Willem Bogaerts
        >
        Application smith
        Kratz B.V.http://www.kratz.nl/
        I don't understand. I know that when the id parameter won't be send
        the code fails. But when I send this field and everything is ok
        watching on www page, but in error_log file there is an entry that the
        InvalidArgsExce ption was throwed, what is untrue because in that case
        I couldn't see right www page on my browser, that means something is
        wrong. And I don't know what :( ? Is anyone had that kind of problem ??

        Comment

        • yaaros@gmail.com

          #5
          Re: error-logs() bug ??

          On 26 Cze, 16:24, Captain Paralytic <paul_laut...@y ahoo.comwrote:
          On 26 Jun, 15:13, yaa...@gmail.co m wrote:
          >
          >
          >
          Hello !! I have a problem with error_logs. The problem is in this
          code:
          >
          $id_tmp = $_REQUEST["id"];
          if(!isset($id_t mp) && empty($id_tmp)) {
          invalidArgs();
          echo "buug";
          >
          }
          >
          I'd like to check if the variable id is passed by GET method to the
          script. If not, function invalidArgs() will start.
          In function invalidArgs() I thrown exception InvalidArgsExce ption. I
          set a handler for whole script to manage exceptions using
          set_exception_h andler(); function. I write, by error_log, errors to
          file and show warning page that the parameter id isn't pass through.
          >
          And the problem is that when I open this page in www browser IE6 and
          put correct parameter id everything is ok, the page that suppose to is
          showing but in file where errors are written (by error_logs), are
          appeared errors of InvalidArgsExce ption ?? That's really weird
          because the script doesn't suppose to get into if-block and start
          function invalidArgs(). What is wrong, why error_log writes an errors
          that doesn't suppose to ?? Everything work correct, the page and the
          rest of the script acts like it gets the id parameter from GET
          methods, but there is entry in error_log file ??
          >
          Try
          >
          if(!isset($_REQ UEST["id"]) || empty($_REQUEST["id"])){
          invalidArgs();
          echo "buug";
          >
          }
          It doesn't work. Still writes me an Exceptions error in errol_log
          file :(

          Comment

          • Michael Fesser

            #6
            Re: error-logs() bug ??

            ..oO(yaaros@gma il.com)
            >Hello !! I have a problem with error_logs. The problem is in this
            >code:
            >
            >$id_tmp = $_REQUEST["id"];
            >if(!isset($id_ tmp) && empty($id_tmp)) {
            invalidArgs();
            echo "buug";
            >}
            >
            >I'd like to check if the variable id is passed by GET method to the
            >script.
            If you're expecting a GET variable then use the $_GET array. The
            $_REQUEST array contains values from three(!) different sources and
            should only be used in very special cases.

            Additionally you should set error_reporting to E_ALL in your php.ini.
            The first line from the code above will cause a notice if no 'id'
            parameter was submitted.

            It should be something like:

            if (!isset($_GET['id'])) {
            invalidArgs();
            echo "buug";
            }

            If you also want to check for empty parameters add an OR condition:

            if (!isset($_GET['id']) || empty($_GET['id'])) {
            invalidArgs();
            echo "buug";
            }

            Micha

            Comment

            • Michael Fesser

              #7
              Re: error-logs() bug ??

              ..oO(yaaros@gma il.com)
              >It doesn't work. Still writes me an Exceptions error in errol_log
              >file :(
              This can't happen with just the little snippet you posted. It's most
              likely something in the rest of your code.

              Do you always get the "buug" output even if there shouldn't be an error
              message? Is InvalidArgs() called somewhere else in the script? Is the
              exception handler working correctly? Are you sure the error message is a
              recent one (do you log a timestamp)?

              Just some guesses.

              Micha

              Comment

              • yaaros@gmail.com

                #8
                Re: error-logs() bug ??

                On 26 Cze, 16:38, Michael Fesser <neti...@gmx.de wrote:
                .oO(yaa...@gmai l.com)
                >
                It doesn't work. Still writes me an Exceptions error in errol_log
                file :(
                >
                This can't happen with just the little snippet you posted. It's most
                likely something in the rest of your code.
                >
                Do you always get the "buug" output even if there shouldn't be an error
                message?
                No the thing is that I haven't got the "buug" output when shouldn't be
                an error.
                Is InvalidArgs() called somewhere else in the script?
                No there is only one place in that script where I call it. I'm sure
                that it is throwing exactly this exception because with the exception
                message I send current date and string that is never repetead in code.
                >Is the exception handler working correctly?
                Habdler seems to work ok, because when I don't pass the id parameter
                it shows me error www page like it suppose to.
                >Are you sure the error message is a recent one (do you log a timestamp)?
                Yes I put the date in message that is written in error_log file and
                its recent.
                >
                Just some guesses.
                >
                Micha
                Thanks but it still doesn't help me :(


                Comment

                • Michael Fesser

                  #9
                  Re: error-logs() bug ??

                  ..oO(yaaros@gma il.com)
                  >On 26 Cze, 16:38, Michael Fesser <neti...@gmx.de wrote:
                  >>
                  >Do you always get the "buug" output even if there shouldn't be an error
                  >message?
                  >
                  >No the thing is that I haven't got the "buug" output when shouldn't be
                  >an error.
                  So you get an error message in your logfile, but no "buug" output? Maybe
                  a backtrace can shed some light on it. In my own exception handler I
                  call the exception's getTraceAsStrin g() method and write the output to
                  the error log. This helps me to figure out where exactly the error
                  occured and what method calls led to it.

                  Apart from that the only idea would be to post (or upload to a website)
                  a _complete_ example code that causes the error. Of course this test
                  case should be as short as possible.

                  Micha

                  Comment

                  • Jerry Stuckle

                    #10
                    Re: error-logs() bug ??

                    yaaros@gmail.co m wrote:
                    Hello !! I have a problem with error_logs. The problem is in this
                    code:
                    >
                    $id_tmp = $_REQUEST["id"];
                    if(!isset($id_t mp) && empty($id_tmp)) {
                    invalidArgs();
                    echo "buug";
                    }
                    >
                    I'd like to check if the variable id is passed by GET method to the
                    script. If not, function invalidArgs() will start.
                    In function invalidArgs() I thrown exception InvalidArgsExce ption. I
                    set a handler for whole script to manage exceptions using
                    set_exception_h andler(); function. I write, by error_log, errors to
                    file and show warning page that the parameter id isn't pass through.
                    >
                    And the problem is that when I open this page in www browser IE6 and
                    put correct parameter id everything is ok, the page that suppose to is
                    showing but in file where errors are written (by error_logs), are
                    appeared errors of InvalidArgsExce ption ?? That's really weird
                    because the script doesn't suppose to get into if-block and start
                    function invalidArgs(). What is wrong, why error_log writes an errors
                    that doesn't suppose to ?? Everything work correct, the page and the
                    rest of the script acts like it gets the id parameter from GET
                    methods, but there is entry in error_log file ??
                    >
                    That is correct.

                    $id_tmp = $_REQUEST["id"];

                    will log a notice if $_REQUEST["id"] is not set. You should be checking
                    it directly instead of setting $id_tmp.


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

                    Comment

                    • yaaros@gmail.com

                      #11
                      Re: error-logs() bug ??

                      I found the reason why is errors written in log file but I still don't
                      understand that :).
                      Before in the code I have got an img tag which was written like that:

                      <img src="?" alt="" width=1 height=1>

                      It have bad src attribute and this causes somehow my problems. When I
                      delete this img tag log file become empty after refreshing pages.
                      Intresting huh ??

                      I have no idea why this tag causes that the first trown exceptions in
                      code was written in log file but it's true.
                      Maybe somena could explain me that ??

                      Thanks for yoours answers

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: error-logs() bug ??

                        yaaros@gmail.co m wrote:
                        I found the reason why is errors written in log file but I still don't
                        understand that :).
                        Before in the code I have got an img tag which was written like that:
                        >
                        <img src="?" alt="" width=1 height=1>
                        >
                        It have bad src attribute and this causes somehow my problems. When I
                        delete this img tag log file become empty after refreshing pages.
                        Intresting huh ??
                        >
                        I have no idea why this tag causes that the first trown exceptions in
                        code was written in log file but it's true.
                        Maybe somena could explain me that ??
                        >
                        Thanks for yoours answers
                        >
                        This is HTML code and wouldn't cause a PHP exception. It would,
                        however, cause an error in the Apache error log relating to the invalid
                        image filename.

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

                        Comment

                        • yaaros@gmail.com

                          #13
                          Re: error-logs() bug ??

                          That's right Michael. This img tag with wrong src attribute causes the
                          second request with invalid args exception. Silly mistake but it takes
                          some time to find it ;). Anyway thanks everyone for help.

                          Comment

                          Working...