Click to See Complete Forum and Search --> : Converting Temps in PHP! Please HELP


duff2481
11-06-2006, 01:32 PM
I know i have an error on line 37 but I don't know what it is -- Any help this is my first program in PHP so i'm a little unsure if i'm doing it correctly

Help is always appreciated -- thank you!!


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org//TR/xhtml1/DTD/xhtml1-transitional.dtd">


<head>

<title>Project 4-2 - Temp Conversion</title>

</head>

<body>


<?php
$intTempCel = 0;

$intTempFahr = 0;

do { //start of the do while loop
$intTempFahr = (($intTempCel * 1.8) + 32)
// calculates the tempFahr and then keeps it to two decimals

print"(Celsius + $intTempCelsius + , Fahrenheit + $intTempFahr + <br />)"
//prints Celsius, then gets the celsius number which incriments and then prints fahrenheit and then gets the calculated number

$intTempCelsius++; //incriments celsius by one each time
} while ($intTempCelsius <= 100) //ends loop below and counts up till 100 and then exits loop


?>


</body>

</html>

The Little Guy
11-06-2006, 01:44 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org//TR/xhtml1/DTD/xhtml1-transitional.dtd">


<head>

<title>Project 4-2 - Temp Conversion</title>

</head>

<body>


<?php
$intTempCel = 0;

$intTempFahr = 0;

while ($intTempCelsius <= 100) { //start of the do while loop
$intTempFahr = (($intTempCel * 1.8) + 32);
// calculates the tempFahr and then keeps it to two decimals

print"(Celsius + $intTempCelsius + , Fahrenheit + $intTempFahr + <br />)";
//prints Celsius, then gets the celsius number which incriments and then prints fahrenheit and then gets the calculated number

$intTempCelsius++; //incriments celsius by one each time
} //ends loop below and counts up till 100 and then exits loop


?>


</body>

</html>

pcthug
11-07-2006, 12:46 AM
Here is a working version of the script. It incorporates the for (http://www.php.net/manual/en/control-structures.for.php) loop:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org//TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Project 4-2 - Temp Conversion</title>
</head>
<body>

<?php
$intTempCel = 0;
$intTempFahr = 0;

for($intTempCelsius = 0; $intTempCelsius < 100; $intTempCelsius++)
{
$intTempCel++;
$intTempFahr = (($intTempCel * 1.8) + 32);

echo "Celsius $intTempCelsius, Fahrenheit $intTempFahr<br />\n";
}
?>

</body>
</html>