Page 1 of 1

Small IF statement problem

Posted: Sat Jan 02, 2010 12:11 pm
by synical21
I must be brain dead today as i can not get this to work. Basically i have two IF statements. I want the secound one to be executed only if the first one is true. This is probably a really simple fix but i am having trouble. Here is the code:

Code: Select all

 
if ($total > 5)
{
if ($percent < 75.0)
{
$sql=mysql_query("UPDATE users SET `banned` = '1' WHERE `id` = '$my_id'") or die( mysql_error() );
}
}
 
:banghead:

Re: Small IF statement problem

Posted: Sat Jan 02, 2010 1:30 pm
by flying_circus
What is $total and $percent?
print $total and $percent just before this function to see what they are set to.

Re: Small IF statement problem

Posted: Sat Jan 02, 2010 1:35 pm
by AbraCadaver
Once you figure that out, you can combine this if this is as simple as it will be:

Code: Select all

if ($total > 5 && $percent < 75)
{
    $sql = mysql_query("UPDATE users SET `banned` = '1' WHERE `id` = '$my_id'") or die( mysql_error() );
}

Re: Small IF statement problem

Posted: Sun Jan 03, 2010 11:00 am
by synical21
Thank you it is now working :)

I just got a quick question but i don't want to open another thread.

My application allows users to withdraw money, to do this a script will check the session $_SESSION['user_money'] to see how much the user has. Is this safe? Can a session value be changed easily?

If carrying a money value in a session is weak i can just make the script grab the amount of money the user has directly from the database instead of checking the session. Just would like to know what i should do :P