Page 1 of 1

Some stupid error $%^&

Posted: Mon Oct 31, 2005 9:29 pm
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

Posted: Mon Oct 31, 2005 9:45 pm
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;

Posted: Mon Oct 31, 2005 11:33 pm
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

Posted: Mon Oct 31, 2005 11:46 pm
by joecrack
Hi
i allready korrekted:

Code: Select all

<input type="checkbox" name="mwst" [color=red]value="ja"[/color]>
still nor working
joe

Posted: Mon Oct 31, 2005 11:52 pm
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

Posted: Tue Nov 01, 2005 12:13 am
by feyd
the decimal in the mutliplier must be a period (.) not a comma (,) .. as I showed in my example...

Posted: Tue Nov 01, 2005 12:24 am
by joecrack
Yeah ... :roll:


thanks a lot
joe