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.
Did you know?Explore Trending and Topic pages for more stories like this.
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
Force download script not handling files with spaces properly
I have a regular old php force download script, uses this code:
Code: header("Cache-Cont
Add 5 to a variable when a button is clicked, and re-run a for loop
So I'm making a feedback sort of section on a website with MySQL and PHP, I've gotten the script to
My query is being run with no results.
I have this.
Code: function DropUser($duser_id, $user_email, $user_username) {
Big Problem!! Please help
Hi Guys,
Im making a website for a friend have encountered a really annoying problem. When ev
PHP url branch??
Functionally, using PHP, I'm doing a test of login input submitted by a user via an html form in a f
Operating System
How in PHP or other language can I detect Operating system, ie Windows XP Home, Windows 7 Ultimate,
Echo multiple lines of html code
Hi guys,
I would like to know if there is a way to echo multiple lines of html codes.
foreach help.
Hello all,
First time I'm attempting to use a foreach statement and was just wondering if my
Why does my php page download images over and over
Can anybody please explain to me why my php page keeps downloading the images and other items every
Multi Dimensional Array Append
Hi Guys
I have a function that returns a multidimentional array eg
$result = functio