Clinton Posted January 5, 2009 Share Posted January 5, 2009 I have this... <?php if (isset($dtypewc)) { ?> <tr><td id='header'> Will Consider a <?php echo $dtypewc; ?>. </td></tr> <?php } ?> Now, my $dtypewc variable is empty but it's still returning the "Will Consider a"... Any ideas why? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/139589-isset-help/ Share on other sites More sharing options...
Maq Posted January 5, 2009 Share Posted January 5, 2009 What is $dtypewc? We will need to see more of your script. Quote Link to comment https://forums.phpfreaks.com/topic/139589-isset-help/#findComment-730238 Share on other sites More sharing options...
premiso Posted January 5, 2009 Share Posted January 5, 2009 <?php if (isset($dtypewc) && !empty($dtypewc)) { ?> <tr><td id='header'> Will Consider a <?php echo $dtypewc; ?>. </td></tr> <?php } ?> empty Quote Link to comment https://forums.phpfreaks.com/topic/139589-isset-help/#findComment-730240 Share on other sites More sharing options...
Clinton Posted January 5, 2009 Author Share Posted January 5, 2009 Ok, Premiso... I did not enter anything into that line (dtypewc) so why did it "set"? How does something "set"? I looked up in the manual but it doesn't say how a variable set's. Thanks for the empty link btw. Quote Link to comment https://forums.phpfreaks.com/topic/139589-isset-help/#findComment-730242 Share on other sites More sharing options...
premiso Posted January 5, 2009 Share Posted January 5, 2009 Ok, Premiso... I did not enter anything into that line (dtypewc) so why did it "set"? How does something "set"? I looked up in the manual but it doesn't say how a variable set's. Thanks for the empty link btw. How is $dtypewc being populated? If it is from a form, chances are register_globals is on and I would suggest turning them off or coding like they are off. Basically register_globals converts and form/session/cookie data to an actual string. So a form with a field name of dtypewc will out populate $dtypewc, when you should do something like this to assign the variable... <?php $dtypewc = (isset($_REQUEST['dtypewc']) && !empty($_REQUEST['dtypewc']))?$_REQUEST['dtypewc']:false; ?> Then your if would be <?php $dtypewc = (isset($_REQUEST['dtypewc']) && !empty($_REQUEST['dtypewc']))?$_REQUEST['dtypewc']:null; if (!is_null($dtypewc)) { ?> <tr><td id='header'> Will Consider a <?php echo $dtypewc; ?>. </td></tr> <?php } ?> That is assuming that is what is happening. Quote Link to comment https://forums.phpfreaks.com/topic/139589-isset-help/#findComment-730249 Share on other sites More sharing options...
Clinton Posted January 5, 2009 Author Share Posted January 5, 2009 It's an option on a form, text type, then the form INSERTS all info into the db. It's actually being populated by SELECT then extract_row(). Quote Link to comment https://forums.phpfreaks.com/topic/139589-isset-help/#findComment-730254 Share on other sites More sharing options...
premiso Posted January 5, 2009 Share Posted January 5, 2009 It's an option on a form, text type, then the form INSERTS all info into the db. It's actually being populated by SELECT then extract_row(). Then it is coming out of the DB it has a value of "" so the variable is created, meaning it was set, thus why you would need to check empty to check if that value has any data or not. You could even remove the isset if you wanted to and just check the empty. Quote Link to comment https://forums.phpfreaks.com/topic/139589-isset-help/#findComment-730273 Share on other sites More sharing options...
Maq Posted January 5, 2009 Share Posted January 5, 2009 if(isset($dtypewc) && trim($dtypewc) != "") { Quote Link to comment https://forums.phpfreaks.com/topic/139589-isset-help/#findComment-730278 Share on other sites More sharing options...
Clinton Posted January 5, 2009 Author Share Posted January 5, 2009 Apparently all sorts of ways I could have done it. LoL. Thanks Premiso... once again. :-) Quote Link to comment https://forums.phpfreaks.com/topic/139589-isset-help/#findComment-730287 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.