KDM Posted August 4, 2011 Share Posted August 4, 2011 if ("$car_class") == FALSE { echo '<span class="warning">*</span>'; } Here is my error thanks Parse error: syntax error, unexpected T_IS_EQUAL in /home/content/30/6371630/html/register.php on line 421 Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/ Share on other sites More sharing options...
Maq Posted August 4, 2011 Share Posted August 4, 2011 Read the manual - http://se2.php.net/manual/en/control-structures.if.php Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1251983 Share on other sites More sharing options...
premiso Posted August 4, 2011 Share Posted August 4, 2011 Since maq is my lover and everything I've ever wanted, just lazy: if ($car_class == FALSE) { //echo here } Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1251984 Share on other sites More sharing options...
AbraCadaver Posted August 4, 2011 Share Posted August 4, 2011 Will evaluate if $car_class evaluates to any value that is considered false: if ($car_class == FALSE) { echo '<span class="warning">*</span>'; } This will do the same: if (!$car_class) { echo '<span class="warning">*</span>'; } This will check to make sure the value is actually boolean false: if ($car_class === FALSE) { echo '<span class="warning">*</span>'; } Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1251985 Share on other sites More sharing options...
IrOnMaSk Posted August 4, 2011 Share Posted August 4, 2011 is that line 421? if ("$car_class") == FALSE { echo '<span class="warning">*</span>'; } here's the structure of if statement if( condition ) { //execute code if condition is true } you didn't close the codition ")" so close the condition after the ==False Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1251990 Share on other sites More sharing options...
AyKay47 Posted August 4, 2011 Share Posted August 4, 2011 in this case if the OP doesnt even understand how to write a simple if statement, i beleive that the manual is the best place for him/her to look and understand PHP..i agree with what Maq posted, will lead to more enlightment here Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1251992 Share on other sites More sharing options...
IrOnMaSk Posted August 4, 2011 Share Posted August 4, 2011 in this case if the OP doesnt even understand how to write a simple if statement, i beleive that the manual is the best place for him/her to look and understand PHP..i agree with what Maq posted, will lead to more enlightment here i usually have a hard time understanding the manual actually because they don't explain much just show you with examples... i go there for syntax not for understanding but not all people are a like we all are unique and special like everyone else lol Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252000 Share on other sites More sharing options...
Maq Posted August 4, 2011 Share Posted August 4, 2011 we all are unique and special like everyone else lol Some of us more than others. *cough* premiso *cough* KDM, did you figure it out? Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252004 Share on other sites More sharing options...
AyKay47 Posted August 4, 2011 Share Posted August 4, 2011 in this case if the OP doesnt even understand how to write a simple if statement, i beleive that the manual is the best place for him/her to look and understand PHP..i agree with what Maq posted, will lead to more enlightment here i usually have a hard time understanding the manual actually because they don't explain much just show you with examples... i go there for syntax not for understanding but not all people are a like we all are unique and special like everyone else lol it is a mixture of text explanation and written examples.. it is absolutely essential to look there to fully understand many PHP concepts.. we all are unique and special like everyone else lol Some of us more than others. *cough* premiso *cough* KDM, did you figure it out? that made me laugh.. Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252005 Share on other sites More sharing options...
IrOnMaSk Posted August 4, 2011 Share Posted August 4, 2011 it is absolutely essential to look there to fully understand many PHP concepts.. totally agree. i feel like the manual is for the elites lol, maybe just me it is absolutely essential to look there to fully understand many PHP concepts.. and there's a fine line between being uniqu/speical and nerd/geek Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252009 Share on other sites More sharing options...
IrOnMaSk Posted August 4, 2011 Share Posted August 4, 2011 Oops the second quote should be this lol Some of us more than others. *cough* premiso *cough* and there's a fine line between being uniqu/speical and nerd/geek Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252012 Share on other sites More sharing options...
KDM Posted August 4, 2011 Author Share Posted August 4, 2011 in this case if the OP doesnt even understand how to write a simple if statement, i beleive that the manual is the best place for him/her to look and understand PHP..i agree with what Maq posted, will lead to more enlightment here i usually have a hard time understanding the manual actually because they don't explain much just show you with examples... i go there for syntax not for understanding but not all people are a like we all are unique and special like everyone else lol thanks, very well said. Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252014 Share on other sites More sharing options...
KDM Posted August 4, 2011 Author Share Posted August 4, 2011 Thanks for the help. I was trying to make it so that if the send button is pressed and $car_class is FALSE it would display the warning. Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252015 Share on other sites More sharing options...
IrOnMaSk Posted August 4, 2011 Share Posted August 4, 2011 if you want to check if the send button was click use if(isset($_POST['subment'])) { if( condition) { //if $car_class is false execute code here } } the isset will check if the button is pressed assument the button is named 'submit' Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252018 Share on other sites More sharing options...
AyKay47 Posted August 4, 2011 Share Posted August 4, 2011 if you want to check if the send button was click use if(isset($_POST['subment'])) { if( condition) { //if $car_class is false execute code here } } the isset will check if the button is pressed assument the button is named 'submit' in this case if it is named.. "subment" ... Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252020 Share on other sites More sharing options...
IrOnMaSk Posted August 4, 2011 Share Posted August 4, 2011 if you want to check if the send button was click use if(isset($_POST['subment'])) { if( condition) { //if $car_class is false execute code here } } the isset will check if the button is pressed assument the button is named 'submit' in this case if it is named.. "subment" ... yup, thnx AK47 i can't type today :'( Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252027 Share on other sites More sharing options...
TOA Posted August 4, 2011 Share Posted August 4, 2011 if you want to check if the send button was click use if(isset($_POST['subment'])) { if( condition) { //if $car_class is false execute code here } } the isset will check if the button is pressed assument the button is named 'submit' @KDM: FYI- this could be condensed into one statement if you wanted; like: if (isset($_POST['submit']) && $car_class == FALSE) { // code to execute } Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252028 Share on other sites More sharing options...
IrOnMaSk Posted August 4, 2011 Share Posted August 4, 2011 if you want to check if the send button was click use if(isset($_POST['subment'])) { if( condition) { //if $car_class is false execute code here } } the isset will check if the button is pressed assument the button is named 'submit' @KDM: FYI- this could be condensed into one statement if you wanted; like: if (isset($_POST['submit']) && $car_class == FALSE) { // code to execute } no, don't do that!!! the, reason, is i'm kidding Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252032 Share on other sites More sharing options...
KDM Posted August 4, 2011 Author Share Posted August 4, 2011 if you want to check if the send button was click use if(isset($_POST['subment'])) { if( condition) { //if $car_class is false execute code here } } the isset will check if the button is pressed assument the button is named 'submit' Thanks for the help! I tried if isset before but didn't use the post variable. And I had to change submit to send. It's working fine now. Thanks a lot. I learned something. Quote Link to comment https://forums.phpfreaks.com/topic/243837-can-someone-show-me-how-to-properly-write-this-short-if-statement/#findComment-1252046 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.