I do this thing:

mysql_query("SELECT * FROM startpoke WHERE id_poke='".$_SESSION['id']."'"); if(life > 0 ){ $res = mysql_query("UPDATE `startpoke` SET `life`=`life`-3 WHERE id_poke='".$_SESSION['id']."'")or die(mysql_error()) ; } else { echo "бе"; } 

I have life more than zero and it displays me "baa". Tell me, please, what to do?

    2 answers 2

    Learn the basics.

     $sql=mysql_query("SELECT * FROM startpoke WHERE id_poke='".$_SESSION['id']."'"); $row=mysql_fetch_array($sql); if($row['life'] > 0 ){ $res = mysql_query("UPDATE `startpoke` SET `life`=`life`-3 WHERE id_poke='".$_SESSION['id']."'")or die(mysql_error()) ; } else { echo "бе"; } 
    • Spasibki =) - k0mar

    Not life , but $life .

    • Yes, he wrote the wrong code. - Ozim
    • Well, it’s not known what life is in there, maybe it’s not all code. Not the fact, that life is a line from a DB. - DemoS
    • I agree that it would be nice to read the basics, than to ask for the implementation of each line. - Maksym Prus 1111
    • four
      Well, as far as I know, they are writing with the joint forces here))) - DemoS
    • Cool language PCP! - avp