mattm1712 Posted September 16, 2011 Share Posted September 16, 2011 hi i have set 2 varibles, and want to echo them out if they are true, i have this script but doesnt work, please help. <?php $month=$_GET['month']; $year=$_GET['year']; If($year!=0 && $month!=0) { echo $month; echo $year; } ?> cheers matt Quote Link to comment https://forums.phpfreaks.com/topic/247301-if-2-varibles-are-true/ Share on other sites More sharing options...
savagenoob Posted September 16, 2011 Share Posted September 16, 2011 Do the variables just have to contain data or be a certain number? PHP has the isset() function and the empty() function. So it would be.... if(!empty($year) && !empty($month)){ echo $month; echo $year; } Quote Link to comment https://forums.phpfreaks.com/topic/247301-if-2-varibles-are-true/#findComment-1270051 Share on other sites More sharing options...
xyph Posted September 16, 2011 Share Posted September 16, 2011 Your code works fine for me, assuming you call you page like I did file.php?year=1&month=2 Quote Link to comment https://forums.phpfreaks.com/topic/247301-if-2-varibles-are-true/#findComment-1270053 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.