mistypotato Posted August 12, 2008 Share Posted August 12, 2008 Hello, Should this work?.... if ($ncvx) $ncustid = 0; else $ncustid = $_GET['ncvx']; thx Quote Link to comment Share on other sites More sharing options...
cdog5000 Posted August 12, 2008 Share Posted August 12, 2008 Hello, Should this work?.... if ($ncvx) $ncustid = 0; else $ncustid = $_GET['ncvx']; thanks if (!$ncvx) $ncustid = 0; else $ncustid = $_GET['ncvx']; try that Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted August 12, 2008 Share Posted August 12, 2008 No, try this: <?php if (isset($_GET['ncvx'])) { $ncustid = 0; }else{ $ncustid = $_GET['ncvx']; } ?> I assume, you want to check if its passed in the URL? Quote Link to comment Share on other sites More sharing options...
mistypotato Posted August 12, 2008 Author Share Posted August 12, 2008 Thanks for the kwik help cdog & monkeypaw ! cdog, i get an error with your code :-( Monkeypaw, with your code, the error is gone, but the value does not seem to be returned? any suggestions ? thx ! Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted August 12, 2008 Share Posted August 12, 2008 Thanks for the kwik help cdog & monkeypaw ! cdog, i get an error with your code :-( Monkeypaw, with your code, the error is gone, but the value does not seem to be returned? any suggestions ? thanks ! I assume, you want to check if the variable ncvx is passed in the URL? (ie http://my.domain.com/page.php?ncvx=something) if so, try this: <?php if(isset($_GET['ncvx'])) { $ncustid = 0; }else{ $ncustid = $_GET['ncvx']; } ?> otherwise, please elaborate.. Quote Link to comment Share on other sites More sharing options...
mistypotato Posted August 12, 2008 Author Share Posted August 12, 2008 Hi monkeypaw, yes, you are correct. I want to check for the existence of the variable in the URL just as you describe. Problem is, the function you wrote for some reason does not return the value if it does exist in the URL unless I add this after your code like this... which defeats the purpose of course :-) if (isset($_GET['ncvx'])) { $ncustid = 0; }else{ $ncustid = $_GET['ncvx']; } $ncustid = $_GET['ncvx']; it's as though the first part works correctly but it ignores the section AFTER the else even if there IS a value in the URL Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted August 12, 2008 Share Posted August 12, 2008 I want to get in on this! <?php $ncustid = (empty($_GET['ncvx'])) ? 0 : $_GET['ncvx']; ?> Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted August 12, 2008 Share Posted August 12, 2008 Hi monkeypaw, yes, you are correct. I want to check for the existence of the variable in the URL just as you describe. Problem is, the function you wrote for some reason does not return the value if it does exist in the URL unless I add this after your code like this... which defeats the purpose of course :-) if (isset($_GET['ncvx'])) { $ncustid = 0; }else{ $ncustid = $_GET['ncvx']; } $ncustid = $_GET['ncvx']; it's as though the first part works correctly but it ignores the section AFTER the else even if there IS a value in the URL oops, my mistake! i reversed things.. this should work: if (isset($_GET['ncvx'])) { $ncustid = $_GET['ncvx']; }else{ $ncustid = 0; } Quote Link to comment Share on other sites More sharing options...
tibberous Posted August 12, 2008 Share Posted August 12, 2008 <?php $ncustid = ($_GET['ncvx']) ? 0 : $_GET['ncvx']; ?> Just as good. I hate people who use isset and empty. Quote Link to comment Share on other sites More sharing options...
mistypotato Posted August 12, 2008 Author Share Posted August 12, 2008 OMG Generic ! That worked perfectly !!!! MANY MANY thanks to all of you you're great Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted August 12, 2008 Share Posted August 12, 2008 Pft tibberous, what if $_GET['ncvx'] is the string 'false'? EDIT: example... <?php $var = 'false'; echo isset($var) == true; // true echo !empty($var) == true; // true echo $var == true; // false ?> There IS an advantage to using empty() or isset() over not using anything. Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted August 12, 2008 Share Posted August 12, 2008 <?php $ncustid = ($_GET['ncvx']) ? 0 : $_GET['ncvx']; ?> Just as good. I hate people who use isset and empty. Somtimes, the simplest ways are the best (BTW don't diss just because you code differently) Quote Link to comment Share on other sites More sharing options...
mistypotato Posted August 12, 2008 Author Share Posted August 12, 2008 Really, thank you all for the fast help ! I had no idea I could get this resolved this evening...so quickly You've all made my night and especially you Generic. You guys really know this stuff ;-) Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted August 12, 2008 Share Posted August 12, 2008 If only all questions could be answered so easily. Quote Link to comment Share on other sites More sharing options...
tibberous Posted August 12, 2008 Share Posted August 12, 2008 Pft tibberous, what if $_GET['ncvx'] is the string 'false'? EDIT: example... <?php $var = 'false'; echo isset($var) == true; // true echo !empty($var) == true; // true echo $var == true; // false ?> There IS an advantage to using empty() or isset() over not using anything. I didn't say it was the same, just that it was 'just as good'. How does someone use the string 'false'? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted August 12, 2008 Share Posted August 12, 2008 I didn't say it was the same, just that it was 'just as good'. How does someone use the string 'false'? a true/false questionaire? o.O Quote Link to comment Share on other sites More sharing options...
tibberous Posted August 12, 2008 Share Posted August 12, 2008 Then your way would have 'false'==true, it would screw it up =) Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted August 12, 2008 Share Posted August 12, 2008 no, my way is empty() !empty('false') == true evaluates to true == true evaluates to true your way is 'false' == true evaluates to false == true evaluates to false you could rectify by doing $str === true for everything, but that's even worse than using empty() edit: spelling I'm just saying using $str instead of !empty($str) does not work 100% of the time, plus it looks messier (to me) Quote Link to comment 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.