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
what business processes?
Hi,
A general question. What business processes (like OTC - Order to Cach, P2P, R2R etc)
strptime() equivalent for php4 ?!
Greetings!
this is my first post, thank you in advance for your replies.
Well, the ti
help, header() is not working!
Hello, I have this code:
<?php
/**
* @author samoi
* @copyright 200
Open browser page depending on XML results
Hello,
I have some PHP code that sends webbased from data to an external url ( in the form of
pop3 and fsockopen
So I am able to connect to the pop3 server, log in, and check how many messages there are. I am hav
need help with date function
i have following form for date
Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
List/Menu Box
On an edit page when you want something to select what a user has previously selected from the datab
php/xmlrpc class issue
I am working on xml-rpc in php to start with.
I have a class that only has variables defined
How to find OS bit version
How can I tell the person browsing my site is running 32, or 64 bit operating system?
type check while uploading
Hi Everyone,
How can I check the exact type of a file while uploading on my site?
Here