Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
May 16th, 2000, 01:52 PM
Junior Member

Join Date: Apr 2000
Posts: 12
Time spent in forums: < 1 sec
Reputation 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");**

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
May 16th, 2000, 02:06 PM
 jonherron
Junior Member

Join Date: May 2000
Posts: 24
Time spent in forums: < 1 sec
Reputation Power: 0
if (\$two >= 10)

perhaps it is thinking that \$two is a string, have you tried converting it to an integer?

#3
May 17th, 2000, 09:51 PM
Junior Member

Join Date: Apr 2000
Posts: 12
Time spent in forums: < 1 sec
Reputation Power: 0
HI jonherron, I will try that. Thanks,
Peter

 Viewing: Dev Shed Forums > Programming Languages > PHP Development > if statements & functions help