Re: Php undefined variable

On 2010-06-12, David Bolt <blacklist-me@xxxxxxxxxx> wrote:
On Friday 11 Jun 2010 17:27, while playing with a tin of spray paint,
Vahis painted this mural:

which gives a 'PHP Notice: Undefined variable' in Apache error log.

Have you checked to see where $days and $uptimeString are defined?

Tried, yes. Php just isn't in my set of skills :(
It's a script that I found long ago, it used to have no errors AFAIR
but after some php version change there's been this notice.


So was I, although I've improved a little bit[0] since the last time I
posted here about PHP and databases[1].

I remember that. That's roughly when I noticed that programming is not
necessarily my cup of tea.
Purchasing a two inch thick book about Php5/MySQL didn't get me

It looks great in the book shelf though.

Try calling the script using the command line.

That gives the same as Apache log. It says
PHP Notice: Undefined variable: uptimeString in uptime.php on line 21

When I look at line 21 in Kate I don't know what the fault there is.
Instead of pasting the whole code here it can be seen at

Another useful thing is to use the cli version to do a syntax check:

davjam@moray:~/sync> php -l test.php
No syntax errors detected in test.php

I get the same.

I've found it comes in very useful when writing big scripts and I
manage to miss off a ';' somewhere.

Great tip for the future :)

[1] I still see spiders looking at director.php and the various sorting
options that were posted :)

I went to OpenDB at that time, rolling my own turned out to be

There were some notices in there, too, after php version change.
I found them and was able to fix them then though.

openSUSE 11.2 (x86_64)
09:06am up 39 days 13:18, 13 users, load average: 0.11, 0.05, 0.06