★ wanayoo — archive 1999 http://www.devshed.com/Talk/Forums/Forum5/HTML/001153.htmlNouvelle recherche | Portail wanayoo
DevShed Menu
* DevShed Home
* Developer News
* DevShed Brain Dump




UBBFriend: Email This Page to Someone!
  DevShed Discussion Forums
  PHP
  if statements & functions help

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   if statements & functions help
badboy
Member
posted May 16, 2000 11:52 AM     Click Here to See the Profile for badboy   Click Here to Email badboy     Edit/Delete Message Reply w/Quote
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
}
}
?>

jonherron
Member
posted May 16, 2000 12:06 PM     Click Here to See the Profile for jonherron   Click Here to Email jonherron     Edit/Delete Message Reply w/Quote
if ($two >= 10)

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

badboy
Member
posted May 17, 2000 07:51 PM     Click Here to See the Profile for badboy   Click Here to Email badboy     Edit/Delete Message Reply w/Quote
HI jonherron, I will try that. Thanks,
Peter

All times are MST (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | DevShed.com

Copyright © 1997-2000 ngenuity. All rights reserved.

Powered by: Ultimate Bulletin Board, Version 5.41a
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.