Wierd if else problem
Posted on
16th Feb 2014 07:03 pm by
admin
Hi guys,
this probably aint wierd for you, but it seems like php is playin up to me. may b i missed something. so i'm kinda needing another set or may more sets of eyes. lol.
this is the code.
while($row = mysql_fetch_array($result)){
$debit = $row['debit'];
$credit = $row['credit'];
$acnum = $row['acnum'];
$query1 = "SELECT cbal FROM accounts WHERE acnum = '$acnum'";
$res = mysql_query($query1);
$balancenum=mysql_num_rows($res);
while($row1 = mysql_fetch_array($res)){
$cbal = $row1['cbal'];
}
If (is_numeric($debit)){
$actype = substr($acnum,0,1);
settype($actype, "integer");
echo $actype;
echo "
";
echo gettype($actype);
echo "
";
If ($actype == 1 || $actype == 5 || $actype == 6 || $actype == {
$cbal = $cbal - $debit;
$sql2="UPDATE accounts SET cbal = '$cbal' WHERE acnum = '$acnum'";
echo "2" . $sql2;
echo "
";
mysql_query($sql2);
} else {
$cbal = $cbal + $debit;
$sql2="UPDATE accounts SET cbal = '$cbal' WHERE acnum = '$acnum'";
echo "2". $sql2;
echo "
";
mysql_query($sql2);
}
}
If (is_numeric($credit)){
$actype = substr($acnum,0,1);
settype($actype, "integer");
echo $actype;
echo "
";
echo gettype($actype);
echo "
";
If ($actype == 1 || $actype == 5 || $actype == 6 || $actype == {
$cbal = $cbal + $credit;
$sql="UPDATE accounts SET cbal = '$cbal' WHERE acnum = '$acnum'";
echo $sql;
echo "
";
mysql_query($sql);
} else {
$cbal = $cbal - $credit;
$sql="UPDATE accounts SET cbal = '$cbal' WHERE acnum = '$acnum'";
echo $sql;
echo "
";
mysql_query($sql);
}
}
}
The wierd thing about the above code is the entire if statement is carried out including the else part.
For example if $actype == 5 it does the stuff that is to be done when the value is 5, AND the stuff to be done in the ELSE section is also carried out.
can you pleaase help me out
No comments posted yet
Your Answer:
Login to answer
94
26
Other forums
What exactly is net neatrality?
What exactly is it? I think it's anti-censorship and... stuff... but I don't really understand it
problems with script
I made a small script wich exchanges points in my website:
<?php
session_start
Combining Two Queries
I have two scripts that each work fine by themselves. One is a search script with a variable that de
Placing and array within an array then sorting it!
I have a page that runs two large mysql queries and saves the results into arrays, in php I then per
unoconv doc convert to pdf code prob
PHP/5.3.1
Hi. I am trying to use this code to convert docs to .pdf utilizing unoconv. Howe
Remove letter from numeric textbox
I have a textbox that will search the employee database by entering in the employee ID and it will r
displaying email without attracting a ton of spam
Hello,
this is maybe the wrong place to ask.
How would you display an email address on a w
php code to accept and delete incoming data
Using following HTML Code please show me how to write PHP code to accept and delete the incoming dat
Find occurences of unicode characters in string
I need to prohibit filenames with everything but English characters and numbers but regexp and strin
using explode() to fill in checkboxes
Hi
I have a field stored in a table that contains regions in the UK separated by commas. Ther