#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    12
    Rep Power
    0
    Keep getting "fatal error" at the "if" statement line & nedd some help. Included the problem code bellow ! many thanks in advance !

    add together the last two digits of the $year. If result is 10 or more, add the two digits together to reduce them to a single digit. Substract from 10. If answer is 5 use the digit 2.
    If year 2000 and beyond* subtract from 9 (instead of 10).

    <?php
    $byear = 1992;
    $first = substr($byear,2,1);* // Use substr to split the digits
    echo("$first<br>");
    $last = substr($byear,3,1);
    echo("$last<br>");

    echo("$first + $last");
    echo"<br>";
    $two = +($first + $last);* // add the 2 digits together
    echo("$two");**
    echo"<BR> how about it";

    if ($two >= 10)* {*******// If $two is* equal to 10 or more, split again************
    $first2 = substr($two,0,1);
    echo("$first2<BR>");
    $last2 = substr($two,1,1);
    echo("$last2<BR>");
    $third = +($first2 + $last2);**// Add together again
    echo"<br>";
    echo("$third");*********// Result is one digit
    $fourth = - (10 - $third);**// Subtract from10
    exit;
    } else* {******//* if value of $two is less than 10
    $fourth = - (10 - $two);** // Subtract from10
    {***********************
    }
    if ($byear >= 2000) {*** // if year is greater or equal to 2000
    $md = - ( $fourth - 1);**// Subtract 1 from $fourth
    } else
    $md = $fourth; {
    }
    if ($md == 5) {****//* If $fourth value equals 5, use 2
    $md = 2;
    else
    $md = $fourth;*** // Else use first instance of value $fourth
    }
    }
    ?>
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    24
    Rep Power
    0
    if ($two >= 10)

    perhaps it is thinking that $two is a string, have you tried converting it to an integer?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    12
    Rep Power
    0
    HI jonherron, I will try that. Thanks,
    Peter

Similar Threads

  1. functions slowing code
    By dave2k in forum PHP Development
    Replies: 5
    Last Post: February 7th, 2004, 06:40 PM
  2. problem with functions
    By veni123 in forum C Programming
    Replies: 8
    Last Post: February 5th, 2004, 02:22 PM
  3. functions & if statements
    By Toka in forum HTML Programming
    Replies: 2
    Last Post: February 5th, 2004, 08:39 AM
  4. Passing pointers between functions
    By heygirls_uk in forum C Programming
    Replies: 2
    Last Post: January 9th, 2004, 02:26 PM
  5. assembly representation of switch statements
    By infamous41md in forum C Programming
    Replies: 3
    Last Post: November 27th, 2003, 05:03 AM

IMN logo majestic logo threadwatch logo seochat tools logo