Jump to content

If statments not working


kasc

Recommended Posts

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. :(
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.
[!--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.
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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.