Page 1 of 1

xampp on winxp (problem)

PostPosted: 28. April 2006 21:05
by fs
Help, some simple php & html program don't work normal in xampp

example:

calcule.html
<form action="bcalcule.php" method="post">
<input type="text" name="za" value="0">
<br>
<select name="acalc">
<option selected>+</option>
<option>-</option>
<option>*</option>
<option>/</option>
</select>
<br>
<input type="text" name="xa" value="0">
<br>
<input type="submit" name="ans" value="ok"><input type="reset" name="reset" value="reset">
</form>

bcalcule.php
<?
$a_acalc="+";
$b_acalc="-";
$c_acalc="*";
$d_acalc="/";

$acalc=$_POST['acalc'];
if($acalc==$a_acalc){
$va = $za + $xa;
echo "answer is $va";
} if($acalc==$b_acalc){
$va = $za - $xa;
echo "answer is $va";
} if($acalc==$c_acalc){
$va = $za * $xa;
echo "answer is $va";
} if($acalc==$d_acalc){
$va = $za / $xa;
echo "answer is $va";
}
?>


I know that my source code is right, but in xampp I get always answer 0

PostPosted: 28. April 2006 21:21
by Wiedmann
I know that my source code is right,

No ;-)

Make a "error_reporting(E_ALL);" at the top of your script and you can see that you have undefined variables.

PostPosted: 28. April 2006 21:43
by fs
I have problem with varibles, I get some values in html file and php file must understand it.
I can write

<?
$a = 4;
echo "$4";
?>
and it work in xampp, when I get value from html files, my program don't work in xampp

PostPosted: 28. April 2006 21:47
by fs
xampp don't report any errors or warning, when I runing this program in xampp local host

PostPosted: 28. April 2006 21:56
by fs
sorry I do mistake with this scripts
<?
$a = 4;
echo "$4";
?>

I mean

<?
$a = 4;
echo "$a";
?>

I just tested this script, what I show you(calcule.html and bcalcule.php) . It work wrong, but don't have errors or warning

PostPosted: 28. April 2006 23:20
by Wiedmann
It work wrong, but don't have errors or warning

You have add the line I told you?

BTW:
when I get value from html files, my program don't work in xampp

Please read the PHP manual about "external variables".