webref.eu Posted August 19, 2008 Share Posted August 19, 2008 Hi All I have to code an statement that says "If not the conditions where processform is 1 AND ErrorMsg is empty string". So far I have this: If !($_POST['processform'] == 1 AND ErrorMsg == "") { which I know is wrong. Can anyone help me correct it? Thanks All. Link to comment https://forums.phpfreaks.com/topic/120371-solved-help-with-if-statement-syntax/ Share on other sites More sharing options...
waynew Posted August 19, 2008 Share Posted August 19, 2008 What about: If ($_POST['processform'] != 1 && ErrorMsg == "") { Link to comment https://forums.phpfreaks.com/topic/120371-solved-help-with-if-statement-syntax/#findComment-620169 Share on other sites More sharing options...
Mchl Posted August 19, 2008 Share Posted August 19, 2008 If ($_POST['processform'] != 1 || ErrorMsg != "") { AND => && OR => || waynewex: de Moragn's laws apply Link to comment https://forums.phpfreaks.com/topic/120371-solved-help-with-if-statement-syntax/#findComment-620170 Share on other sites More sharing options...
waynew Posted August 19, 2008 Share Posted August 19, 2008 Sorry didn't focus on logic. Just seen the script and corrected it without reading what he had said. Link to comment https://forums.phpfreaks.com/topic/120371-solved-help-with-if-statement-syntax/#findComment-620172 Share on other sites More sharing options...
Mchl Posted August 19, 2008 Share Posted August 19, 2008 Sorry didn't focus on logic. Just seen the script and corrected it without reading what he had said. webref.eu: syntax in general is: if (condition) { } condition is always in () parentheses Link to comment https://forums.phpfreaks.com/topic/120371-solved-help-with-if-statement-syntax/#findComment-620175 Share on other sites More sharing options...
webref.eu Posted August 19, 2008 Author Share Posted August 19, 2008 Guys, I still don't think I have this right. Let me explain further: Under these conditions: $_POST['processform'] == 1 AND ErrorMsg == "" I don't want a form to be displayed, so I have to write and If statement saying If Not both the above mentioned conditions. If think it's something like: If !(($_POST['processform'] == 1) && (ErrorMsg == "")) { but this still isn't quite right as I'm getting an unexpected ! error. Thanks all. Link to comment https://forums.phpfreaks.com/topic/120371-solved-help-with-if-statement-syntax/#findComment-620179 Share on other sites More sharing options...
Mchl Posted August 19, 2008 Share Posted August 19, 2008 condition is always in () parentheses If ($_POST['processform'] != 1) && (ErrorMsg != "") { or If (!($_POST['processform'] == 1 || ErrorMsg == "")) { Besides, I believe ErrorMsg is a variable so: $ErrorMsg Link to comment https://forums.phpfreaks.com/topic/120371-solved-help-with-if-statement-syntax/#findComment-620196 Share on other sites More sharing options...
webref.eu Posted August 19, 2008 Author Share Posted August 19, 2008 Thanks for your help with the logic statement. Here is the code that I have found to work the way I wanted regarding when to display the form: <?php If (!($_POST['processform'] == 1 && $ErrorMsg == "")) { ?> <!-- display the form --> <form> ... </form> <?php //end if } ?> Rgds Link to comment https://forums.phpfreaks.com/topic/120371-solved-help-with-if-statement-syntax/#findComment-620229 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.