Some stupid error $%^&

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
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Some stupid error $%^&

Post by joecrack »

Hi
i tried to write a script wich calculates dollar, euro, yen, pes to chinese YUAN. Working
But then i tried to add checkbox that calculates the MWST its "added value tax" - not working!

Code: Select all

<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Euro-Rechner</title></head>
<body>
<center>

<?php
$ergebnisDollar = $betrag*8.29;
$ergebnisEuro = $betrag*10.09;
$ergebnisYen = $betrag*8.0358;
$ergebnisPES = $betrag*0.00;

if($mwst=ja){
	switch($rate)
  	{
   	case 'Dollar':
   	echo 'Dies sind '.$ergebnisDollar*1,16.' Yuan'; break;
   	case 'Euro':
  	echo 'Dies sind '.$ergebnisEuro*1,16.' Yuan'; break;
  	case 'Yen':
  	echo 'Dies sind '.$ergebnisYen*1,16.' Yuan'; break;
  	case 'PES':
  	echo 'Dies sind '.$ergebnisPES*1,16.' Yuan'; break;
  	}
}
else{
	switch($rate)
  	{
   	case 'Dollar':
   	echo 'Dies sind '.$ergebnisDollar.' Yuan'; break;
   	case 'Euro':
  	echo 'Dies sind '.$ergebnisEuro.' Yuan'; break;
  	case 'Yen':
  	echo 'Dies sind '.$ergebnisYen.' Yuan'; break;
  	case 'PES':
  	echo 'Dies sind '.$ergebnisPES.' Yuan'; break;
  	}
}
?>

</center>
<h2>Ausgangswährung</h2>
<form action="rmb.php" method="post">
<select name="rate">
<option value="Dollar">Dollar</option>
<option value="Euro">Euro</option>
<option value="Yen">Yen</option>
<option value="PES">Pesetes</option>
</select><br><br>
<b>Mwst</b>
<input type="checkbox" name="mwst" value="checkbox"><br><br>
<b>Betrag</b><br>
<input type="text" name="betrag" size="20">
<input type="submit" name="submit" value="Berechnen">
</form></body></html>
Perhaps this is wrong:
'.$ergebnisDollar*1,16.'
I didnt realy know how to write it.
PLZ HELP

thx
joe
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

multiple things are actually wrong:

Code: Select all

if($mwst=ja){
should be

Code: Select all

if($mwst=='ja'){
or

Code: Select all

if($mwst==ja){
and

Code: Select all

echo 'Dies sind '.$ergebnisDollar*1,16.' Yuan'; break;
should be

Code: Select all

echo 'Dies sind '.($ergebnisDollar*1.16).' Yuan'; break;
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

I changed everything but still nor working.
Also i had to write it this:

Code: Select all

if($mwst=='ja'){
	switch($rate)
  	{
   	case 'Dollar':
   	echo 'Dies sind .($ergebnisDollar*1,16). Yuan'; break;
   	case 'Euro':
  	echo 'Dies sind .($ergebnisEuro*1,16). Yuan'; break;
  	case 'Yen':
  	echo 'Dies sind .($ergebnisYen*1,16). Yuan'; break;
  	case 'PES':
  	echo 'Dies sind .($ergebnisPES*1,16). Yuan'; break;
  	}
}
But still its doesn't mulitply with with 1.16 !?!?!
till
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

Hi
i allready korrekted:

Code: Select all

<input type="checkbox" name="mwst" [color=red]value="ja"[/color]>
still nor working
joe
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

If i write it like this:

Code: Select all

if($mwst=='ja'){
	switch($rate)
  	{
   	case 'Dollar':
   	echo 'Dies sind '.($ergebnisDollar*1,16).' Yuan'; break;
I get

Code: Select all

Dies sind '.(803.58*1,16).' Yuan
^^
Whats wrong
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the decimal in the mutliplier must be a period (.) not a comma (,) .. as I showed in my example...
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post by joecrack »

Yeah ... :roll:


thanks a lot
joe
Post Reply