Undefined variable [message #181235] |
Wed, 24 April 2013 02:16 |
Question Boy
Messages: 8 Registered: April 2011
Karma:
|
Junior Member |
|
|
I have an simple MySQL/PHP app and it appears to be functional but the
webmaster has informed me that it is throwing lots of errors. So he
showed me the log file and I am trying to remedy the issues, but have
a question.
For instance, I have a block of code, such as:
if ($iBookedBy=="Other") {
echo '<option selected value="Other">Other</option>';
} else {
echo '<option value="Other">Other</option>';
}
which the log file reports as:
PHP Notice: Undefined variable: iBookedBy
Now I thought of trying:
if (isset($iBookedBy)==TRUE && $iBookedBy=="Other") {
echo '<option selected value="Other">Other</option>';
} else {
echo '<option value="Other">Other</option>';
}
but am not sure if the server will break because the variable isn't
set or if it will still throw an error because of the second,
original, part of the if statement? Is this a good way to handle the
problem, or am I going about this the wrong way and there is a better
method?
Thank you for your help.
QuestionBoy
|
|
|