2 Replies - 283 Views - Last Post: 11 September 2012 - 06:55 PM Rate Topic: -----

#1 Dan_man  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 11-September 12

PHP Change Maker Program - syntax error

Posted 11 September 2012 - 02:36 PM

Hi i'm new here like just joined, but have been lurking and soaking up info for a while and this forum has been a wealth of information for me. However, today i am stumped on some code. I am supposed to create a change maker. More specifically create a complete program with php and html that will take any number between 1 and 99cents and determine the number of coins that make up the entered number. Here is what i have so far- The part i need some guidance on is line 6, I get a syntax error for $Amount and $originalAmount. Thanks for any help anyone can provide.

<?php

$originalAmount=$_POST{'value'}

//convert input to an integer
$Amount=('integer')$originalAmount;


//get the number of quarters
$quarter= $Amount/25;

//get remainder
$amount=$Amount%25;

//out of the remainder, find how many 10s are in it and repeat the process

$dimes=$amount/10;
$amount=$amount%10;

$nickels=$amount/5;
$amount=$amount%5;

$pennies=$amount/1;
$amount=$amount%1;


//print results onto the screen
print (($originalAmount). "Can be given as:");
print "<br>";
print ((integer)$quarters. "quarters");
print "<br>";
print ((integer)$dimes. "dimes");
print "<br>";
print ((integer)$nickels. "nickels");
print "<br>";
print ((integer)$pennies. "pennies");
print "<br>";

?>



And my HTML

<head>
<title>Change Maker</title>
</head>
<body>
<form action="ChangeMaker.php" method="post">
Convert to change
<input type='number' name='value'>
<br></br>
<input type=submit value="Make Change">
</form>

</body>



Is This A Good Question/Topic? 0
  • +

Replies To: PHP Change Maker Program - syntax error

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5667
  • View blog
  • Posts: 22,509
  • Joined: 23-August 08

Re: PHP Change Maker Program - syntax error

Posted 11 September 2012 - 03:00 PM

The manual page on $_POST.

Pay close attention to how it's used, and compare to how you've used it.

EDIT:

$Amount=('integer')$originalAmount;


The manual page on type juggling (and casting). Again, compare how it's done with how you're doing it.
Was This Post Helpful? 3
  • +
  • -

#3 Dan_man  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 11-September 12

Re: PHP Change Maker Program - syntax error

Posted 11 September 2012 - 06:55 PM

View PostJackOfAllTrades, on 11 September 2012 - 03:00 PM, said:

The manual page on $_POST.

Pay close attention to how it's used, and compare to how you've used it.

EDIT:

$Amount=('integer')$originalAmount;


The manual page on type juggling (and casting). Again, compare how it's done with how you're doing it.


Thanks JackOfAllTrades for the quick reply i'll check out the links.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1