Page 1 of 1

Logging from a PHP Notice

Posted: Fri Jan 04, 2008 2:36 pm
by SpecialK
Glad to see I can finally get my DNS to find the site! It's been hectic few days searching for help, so maybe someone here can shed some light on my problem.

I have some legacy code that is present on a live program.

The error I get is:
[client x.x.x.x] PHP Notice: Undefined offset: 3 in /.../x.php on line 70
by the line:

Code: Select all

list($a,$b,$c,$d) = split(":", $retValues);
Now this is a DB query from a delimited list that is returned. How can I find out more information about this issue when the PHP Notice is thrown? I was thinking something similar to a try/catch to get the information, but wasn't sure. My initial idea was a function like if(PHP_NOTICE) or something like that to run something when the Notice is thrown.

What would be the best solution to find out what is actually being set in $retValues (only when the issue happens). I can't feasibly do it everytime because it is a live program now. It's not an issue the users themselves notice, but I would rather clean up the code to the best possible. I don't want any coding errors to be in the logs.

Re: Logging from a PHP Notice

Posted: Fri Jan 04, 2008 4:53 pm
by alex.barylski
http://ca3.php.net/manual/en/function.s ... andler.php

So the error is being caused when $retValues doesn't have the proper number of delimited values?

Personally I would just supress the error (if legacy code) or write a script to fix the database by ensuring each field has the proper number of ':' delimiters so that each list() = split() at least returns empty values...

Cheers :)

Re: Logging from a PHP Notice

Posted: Tue Jan 15, 2008 2:44 pm
by SpecialK
I "could" suppress the error, but this is legacy code that I created over a year ago. I believe it's up to me to fix it.

I am currently implementing a way to email me the $retValues so I can see the actual array and try to debug. The script it's calling from delimits everything by the colon, so even blank fields should be fine. Maybe they aren't, I believe when I see a full variable dump of $retValues then I will understand more what the issue is.