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 Like 26 Dislike
Previous forums Next forums
Other forums

Session
I am having a little trouble with a session. Not sure if it is my browser or what. I know I do not

PHP Upload issue
Hi guys,

I have stumble across an interesting issue with my script and is doing my head in.

Displaying a clickable playername
I am going wrong somewhere with the mysql_query, can someone please put me straight?

$playern

Else statement screws up all css
Does anyone know what goes wrong in the process with this php code?
This code seems to be causing

Company Code for Vendors created through Business Partners
Hi, experts!

I'm trying to set up the integration between Business Partner (BP) and Vendo

Include ("Absolute Path") of a file?
I'm not sure what I'm doing wrong. I am writing my php code in the same directory of the file that

Inter Company -- Resources Related Billing (Services Industry)
Hello,

My company has a scenario where:
Company A bills Company C for INTER (cross

ok i need to join all this pages to make 1 neat code
i have 5 pages that make up my tv guide it works 100% but i want to make it 1 page if i can or 2, i

setcookie and isset($_COOKIE(name)) seem very finnicky.
I'm currently playing around with a user system with login and registration. I'm trying to use cooki

Query failed issue with php script but works fine in mssql manager!
hi i have the script below which copies data from one table to another but will only insert new data

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash