kasc Posted March 18, 2006 Share Posted March 18, 2006 Ok, this script at the moment isn't working for the catching the errors. Here it is:[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Your Result</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><?php$start = $_POST["start"];$end = $_POST["end"];echo "$start $end<br>";$errors = 0;if ($start = "unchoosen" || $end = "unchoosen" || $start >= $end) { echo "ERRORS:<br>"; if ( $start = "unchoosen" ) { echo "<br> You did not choose your starting value for your item!"; $errors = $errors + 1; } if ( $end = "unchoosen" ) { echo "<br> You did not choose your desired value for your item!"; $errors = $errors + 1; } if ( $start >= $end ) { echo "<br> Your combination of upgrading values are impossible!"; $errors = $errors + 1; } echo "<br>Total Errors: $errors"; }?></body></html>[/code] $start and $end are taken from a drop down box, and they return the right values, jsut the if statement not working, since no matter what the combination (Possible values $start = "unchoosen", 0-8; $end = "unchoosen", 1-9) It always ehcos all 3 errors. :( Link to comment https://forums.phpfreaks.com/topic/5222-if-statments-not-working/ Share on other sites More sharing options...
Barand Posted March 18, 2006 Share Posted March 18, 2006 if ($start [!--coloro:#FF6666--][span style=\"color:#FF6666\"][!--/coloro--]=[!--colorc--][/span][!--/colorc--] "unchoosen"To compare values use "==" and not "="In the statement above you have set the value of $start to "unchoosen" instead of comparing it. Link to comment https://forums.phpfreaks.com/topic/5222-if-statments-not-working/#findComment-18529 Share on other sites More sharing options...
kasc Posted March 18, 2006 Author Share Posted March 18, 2006 [!--quoteo(post=356122:date=Mar 18 2006, 09:31 AM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Mar 18 2006, 09:31 AM) [snapback]356122[/snapback][/div][div class=\'quotemain\'][!--quotec--]if ($start [!--coloro:#FF6666--][span style=\"color:#FF6666\"][!--/coloro--]=[!--colorc--][/span][!--/colorc--] "unchoosen"To compare values use "==" and not "="In the statement above you have set the value of $start to "unchoosen" instead of comparing it.[/quote]^_^ Thanks for that. Link to comment https://forums.phpfreaks.com/topic/5222-if-statments-not-working/#findComment-18531 Share on other sites More sharing options...
kasc Posted March 18, 2006 Author Share Posted March 18, 2006 Another snag, this is returning Parse error: parse error, unexpected '$' in /home/kascgam/public_html/upgrading/upgrading.php on line 43[code]if ( $start !== "unchoosen" && $end !== "unchoosen" && $start < $end ) { $items = 1; /* LINE 43 start = 0 */ if ($start == 0 $$ $end == 1) { $items = 2; } elseif ($start == 0 $$ $end == 2) { $items = 4; } elseif ( start == 0 $$ $end == 3) { $items = 10; } elseif ($start == 0 $$ $end == 4) { $items = 28; } elseif ($start == 0 $$ $end == 5) { $items = 82; } elseif ($start == 0 $$ $end == 6) { $items = 244; } elseif ($start == 0 $$ $end == 7) { $items = 730; } elseif ($start == 0 $$ $end == 8) { $items = 2188; } elseif ($start == 0 $$ $end == 9) { $items = 6562; } /* start = 1 */ echo "You need $items +1 items"; }[/code](Line 43 is the top comment) Link to comment https://forums.phpfreaks.com/topic/5222-if-statments-not-working/#findComment-18539 Share on other sites More sharing options...
Barand Posted March 18, 2006 Share Posted March 18, 2006 if ($start == 0 [!--coloro:#FF6666--][span style=\"color:#FF6666\"][!--/coloro--]$$[!--colorc--][/span][!--/colorc--] $end == 1) { Link to comment https://forums.phpfreaks.com/topic/5222-if-statments-not-working/#findComment-18542 Share on other sites More sharing options...
wildteen88 Posted March 18, 2006 Share Posted March 18, 2006 Rather than two [b]$$[/b] I think you will want either teo [b]||[/b] (|| means OR) or two [b]&&[/b] (&& meaning AND). Link to comment https://forums.phpfreaks.com/topic/5222-if-statments-not-working/#findComment-18549 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.