Re: error-logs() bug ??

This is a discussion on Re: error-logs() bug ?? within the PHP Language forums, part of the PHP Programming Forums category; yaaros@gmail.com wrote: > Hello !! I have a problem with error_logs. The problem is in this > code: > &...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-27-2007
Jerry Stuckle
 
Posts: n/a
Default Re: error-logs() bug ??

yaaros@gmail.com wrote:
> 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 not, function invalidArgs() will start.
> In function invalidArgs() I thrown exception InvalidArgsException. I
> set a handler for whole script to manage exceptions using
> set_exception_handler(); 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 InvalidArgsException ?? 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@attglobal.net
==================
Reply With Quote
  #2 (permalink)  
Old 06-27-2007
yaaros@gmail.com
 
Posts: n/a
Default 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

Reply With Quote
  #3 (permalink)  
Old 06-27-2007
Jerry Stuckle
 
Posts: n/a
Default Re: error-logs() bug ??

yaaros@gmail.com 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@attglobal.net
==================
Reply With Quote
  #4 (permalink)  
Old 06-27-2007
Michael Fesser
 
Posts: n/a
Default Re: error-logs() bug ??

..oO(yaaros@gmail.com)

>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 ??


Logical. The URL in the 'src' attribute is empty. When resolving that,
the browser starts with the base URL, which is usually the one of the
current document unless you use a 'base' element. So in fact requesting
the image leads to a second request of the same page, but with an empty
query string -> exception.

You could also write the content of $_SERVER['REQUEST_URI'] to your
error log to see that.

Micha
Reply With Quote
  #5 (permalink)  
Old 06-28-2007
yaaros@gmail.com
 
Posts: n/a
Default 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.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:29 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0