Undefined variable

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
egoo
-


Joined: 22 Jan 2008
Posts: 16

PostPosted: Mon Jun 02, 2008 7:29 pm    Post subject: Undefined variable Reply with quote

<?php
echo '<p>Order processed at';
echo date ('H:i, jS F');
echo ' </p> ';

$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty; //fatal error:undefined variable:
// tireqty, oilqty, sparkqty
echo 'Items ordered: '.$totalqty.'<br/>';

$totalamount = 0.00;

define('TIREPRICE',100);
define('OILPRICE',10);
define('SPARKPRICE',4);

$totalamount = $tireqty * TIREPRICE //undefined variable:
//tireqty,oilqty,sparkqty
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;

echo 'Subtotal: $'.number_format($totalamount,3).'<br/>';

$taxrate = 0.10;
$totalamount = $totalamount * (1 + $taxrate) ;
echo 'Total including tax: $'.number_format($totalamount,2).'<br/>';
?>
Back to top View user's profile Send private message
DonQuichote
-


Joined: 24 Dec 2006
Posts: 68
Location: The Netherlands

PostPosted: Tue Jun 03, 2008 12:03 am    Post subject: What is the question? Reply with quote

I think the error message is perfectly clear: you use variable contents without putting a value into them first. So the values are undefined.
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group