tet3828 Posted January 24, 2008 Share Posted January 24, 2008 what is the deal with the "OR" in the IF statement? I tried this: if ($_POST['sYear'] or $_POST['sDay'] or $_POST['sMonth']== xxx) { do whatever } Why isn't this working? My translation of the above is IF xxx is passed for either of these 3 variables Do this... What my malfunction here? thanks in advance Link to comment https://forums.phpfreaks.com/topic/87585-amateur-if-statement/ Share on other sites More sharing options...
revraz Posted January 24, 2008 Share Posted January 24, 2008 By saying just IF ($_POST['sYear'] you are checking if it exists, not if it == to xxx Also, it's better to use || instead of OR Link to comment https://forums.phpfreaks.com/topic/87585-amateur-if-statement/#findComment-447964 Share on other sites More sharing options...
kenrbnsn Posted January 24, 2008 Share Posted January 24, 2008 You need to do each comparison: <?php if ($_POST['sYear'] == 'xxx' || $_POST['sDay'] == 'xxx' || $_POST['sMonth'] == 'xxx') { // do whatever } ?> Ken Link to comment https://forums.phpfreaks.com/topic/87585-amateur-if-statement/#findComment-447977 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.