Connecting Tech Pros Worldwide Forums | Help | Site Map

error-logs() bug ??

yaaros@gmail.com
Guest
 
Posts: n/a
#1: Jun 26 '07
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 ??


Captain Paralytic
Guest
 
Posts: n/a
#2: Jun 26 '07

re: error-logs() bug ??


On 26 Jun, 15:13, yaa...@gmail.com wrote:
Quote:
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 ??
Try

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

Willem Bogaerts
Guest
 
Posts: n/a
#3: Jun 26 '07

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.
Quote:
if(!isset($id_tmp) && empty($id_tmp)){
invalidArgs();
echo "buug";
}
This part will not be reached, because the code fails before this block.
Quote:
..., 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().
Best regards,
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
yaaros@gmail.com
Guest
 
Posts: n/a
#4: Jun 26 '07

re: error-logs() bug ??


On 26 Cze, 16:16, Willem Bogaerts
<w.bogae...@kratz.maardanzonderditstuk.nlwrote:
Quote:
Quote:
$id_tmp = $_REQUEST["id"];
>
This fails if there is no index "id", that is, if there is no id field sent.
>
Quote:
if(!isset($id_tmp) && empty($id_tmp)){
invalidArgs();
echo "buug";
}
>
This part will not be reached, because the code fails before this block.
>
Quote:
..., 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().
>
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
InvalidArgsException 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 ??

yaaros@gmail.com
Guest
 
Posts: n/a
#5: Jun 26 '07

re: error-logs() bug ??


On 26 Cze, 16:24, Captain Paralytic <paul_laut...@yahoo.comwrote:
Quote:
On 26 Jun, 15:13, yaa...@gmail.com wrote:
>
>
>
Quote:
Hello !! I have a problem with error_logs. The problem is in this
code:
>
Quote:
$id_tmp = $_REQUEST["id"];
if(!isset($id_tmp) && empty($id_tmp)){
invalidArgs();
echo "buug";
>
Quote:
}
>
Quote:
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.
>
Quote:
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 ??
>
Try
>
if(!isset($_REQUEST["id"]) || empty($_REQUEST["id"])){
invalidArgs();
echo "buug";
>
}
It doesn't work. Still writes me an Exceptions error in errol_log
file :(

Michael Fesser
Guest
 
Posts: n/a
#6: Jun 26 '07

re: error-logs() bug ??


..oO(yaaros@gmail.com)
Quote:
>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
Michael Fesser
Guest
 
Posts: n/a
#7: Jun 26 '07

re: error-logs() bug ??


..oO(yaaros@gmail.com)
Quote:
>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
yaaros@gmail.com
Guest
 
Posts: n/a
#8: Jun 26 '07

re: error-logs() bug ??


On 26 Cze, 16:38, Michael Fesser <neti...@gmx.dewrote:
Quote:
.oO(yaa...@gmail.com)
>
Quote:
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.
Quote:
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.
Quote:
>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.
Quote:
>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.
Quote:
>
Just some guesses.
>
Micha
Thanks but it still doesn't help me :(


Michael Fesser
Guest
 
Posts: n/a
#9: Jun 26 '07

re: error-logs() bug ??


..oO(yaaros@gmail.com)
Quote:
>On 26 Cze, 16:38, Michael Fesser <neti...@gmx.dewrote:
Quote:
>>
>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 getTraceAsString() 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
Jerry Stuckle
Guest
 
Posts: n/a
#10: Jun 27 '07

re: error-logs() bug ??


yaaros@gmail.com wrote:
Quote:
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
==================
yaaros@gmail.com
Guest
 
Posts: n/a
#11: Jun 27 '07

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

Jerry Stuckle
Guest
 
Posts: n/a
#12: Jun 27 '07

re: error-logs() bug ??


yaaros@gmail.com wrote:
Quote:
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
==================
yaaros@gmail.com
Guest
 
Posts: n/a
#13: Jun 28 '07

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.

Closed Thread