Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Bradley Hill
Bradley Hill
1,263 Points

Error issues. I'm sure it's something simple but I'm about to throw my monitor. :D

Keep getting this... https://teamtreehouse.com/library/creating-a-unit-conversion-tool (for reference)

PHP Parse error: syntax error, unexpected '$miles' (T_VARIABLE), expecting ',' or ';' in /home/treehouse/workspace/units.php on line 16

Parse error: syntax error, unexpected '$miles' (T_VARIABLE), expecting ',' or ';' in /home/treehouse/workspace/units.php on line 16

Not sure what the issue is. As far as I'm concerned my code looks the same as the code in the video.

<?php
  // number in pounds we want to convert to kilograms
$pounds = 140;
  // floating point value for the pound to kilogram conversion
$lb_to_kg = 0.453592;
  // use variables above to calculate pounds multiplied by the kilogram conversion
$kilograms = $pounds * $lb_to_kg;
  // display the punds to kilograms
echo "Weight: ";
echo $pounds;
echo " lb = ";
echo $kilograms;
echo " kg"

  // number in miles we want to convert to kilometers
$miles = 2.5;
  //floating point value for the mile to kilometer conversion
$mile_to_km = 1.60934;
  // use the variable above to calculate miles multiplied by the kilometer conversion
$kilometers = $miles * $mile_to_km;
  // display the miles to kilometers
echo "Distance: ";
echo $miles;
echo " miles = ";
echo $kilometers;
echo " km";
?>

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're missing a semicolon on this line:

echo " kg"

That should be:

echo " kg";

Add that semicolon and see if you see a difference! :sparkles:

Bradley Hill
Bradley Hill
1,263 Points

That worked. I knew it would be something obvious. Thanks for the second set of eyes!