You are here: Re: variable problem in address book script « All PHP « IT news, forums, messages
Re: variable problem in address book script

Posted by Geoff Berrow on 01/02/07 10:40

Message-ID: <8K-dnU4b54oOWQTYnZ2dnUVZ_uuqnZ2d@adelphia.com> from Mr.
Newt contained the following:

>> Why not write your own?
>
>I really don't know anything about PHP except what I picked up over the past
>2 weekends during free time. I'm beginning to think I should get a PHP for
>dummies book.

This script probably won't work with the fix for the previous one.

If you haven't the time to learn PHP properly it may be as well to make
your system the same as the ones the code you are 'borrowing'.

The error reporting on your new system is set to show ALL errors.
Previous installations were set to suppress notices, which don't
necessarily stop the code from working. It's generally accepted that
you should code with all errors showing nowadays but as you have found,
there are plenty of old scripts out there.

So the quick and dirty fix is to add
error_reporting(E_ALL ^ E_NOTICE);
to the top of your code. This will suppress notices.
http://uk2.php.net/manual/en/function.error-reporting.php

Why is this necessary? Well in the code you showed us you have things
like:

if($variable){
//do something
}

Now, if $variable does not exist you will get an undefined variable
notice. However, in this case the coder does not care, s/he only wants
the condition executed if the variable exists. And with the default
condition of notices suppressed he cannot see the notice anyway.

Coding it yourself, the modern way with all notices showing you would
write

if(isset($variable)){
//do something
}

I respectfully suggest you avoid this kind of fixing until you have
learned a little more.


--
Geoff Berrow 0110001001101100010000000110
001101101011011001000110111101100111001011
100110001101101111001011100111010101101011

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация