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 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; } 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 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
Archived
This topic is now archived and is closed to further replies.