FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Undefined variable
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Undefined variable [message #181235] Wed, 24 April 2013 02:16 Go to previous message
Question Boy is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Rejecting Certain Non-ASCII Characters
Next Topic: determine a mysqli_result object
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 17:52:04 GMT 2024

Total time taken to generate the page: 0.05357 seconds