Please can someone correct this for me

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Please can someone correct this for me

Post by phelpsa »

Code: Select all

<?php

$wheelsize = $_POST['wheeldiameter'];
$tyrediameter = $_POST['tyrediameter'];
$tyrewidth = $_POST['tyrewidth'];
$inch = '25.4';

$sidewall = $tyrediameter - $wheelsize;
$tyrewidthmm = $tyrewidth * $inch;
$sidewallmm = $sidewall * $inch;
$profile = $sidewallmm / $tyrewidthmm;

echo 'Your tyre size is '$tyrewidthmm'/'$profile'  '$wheelsize ;

?>
Please could someone correct this for me. Where abouts does it need a ',' or ';' in line 13?

Adam
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

You're not concatenating the strings with periods. Try this:

Code: Select all

echo 'Your tyre size is '.$tyrewidthmm.'/'.$profile.'  '.$wheelsize ;
phenom| fixed typo
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

You can simply write the vars into the text string when you use double quotes.

Code: Select all

echo "Your tyre size is $tyrewidthmm/$profile $wheelsize" ;

if you want to use the single quotes then you need to concatenate the vars into the string with the . concatenation operator

Code: Select all

echo 'Your tyre size is '.$tyrewidthmm.'/'.$profile.' '.$wheelsize;
phelpsa
Forum Commoner
Posts: 48
Joined: Thu Feb 17, 2005 1:05 pm

Post by phelpsa »

Thanks guys!
Post Reply