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

Redirecting Admin
In my members table, I have a field called "perm" and it's set to zero for all members. Ho

I have a parse error in this query help..
Code: $query1="INSERT INTO `rating` (`item_name`, `rating`, `ip_address`, `date_rated`) VALUES

retrieving more than one max key from an array?
so i have an array of 20 numerical values (0-100) that i need to order from highest to lowest and th

HTML Email rec'd as Source Code
The code does create and send the email successfully. However, the message shows as html code and n

if statements problems
Hi. I'm trying to make a web form, but I kind of hit a dead end trying to figure out why it doesn't

i have no idea why this isn't working
Code: <?php
session_start();
include("connect.php");

error_reporting(E

apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?

Keeping data in form
How can I keep whatever I write in the form?

convert pps to wsf with php'how?
hi
i want to convert with php
PowerPoint file to swf file(flash)
how please?
thank!!!

Form Help
Here is the form:

Line number On/Off | Expand/Contract<? include("../include/sess

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