IF statement not working for some reason

When i run this code, busts will go up, but bust streak will stay at 0, if i remove the if statement, both will go up, but i need bust streak to only go up if busts = the same value

so bust streak = 2 the only way bust streak should go to 3 is if you have 2 busts in a row then both will = 3

$bust1 = $row['busts'];
$bust2 = $row['buststreak']; 

mysql_query("UPDATE users SET `busts`=`busts`+'1' WHERE username='$username'");

if($bust1 >= $bust2){
mysql_query("UPDATE users SET `buststreak`+'1' WHERE username='$username'");
}

deprecated function + deprecated function = deprecated function https://www.php.net/manual/en/function.mysql-query
should switch over to this (It’s not as simple as adding an “i”)
https://www.php.net/manual/en/mysqli.query.php

my server has an option to pay $7 per month to use php 5.6 until all my pages have been updated to pdo

The second query isn’t actually setting the buststreak column to anything, so, as shown, this never worked. If the buststreak column is getting changed, it’s not due to that query.

You shouldn’t update a column in a table to keep track of changes in a value. as this doesn’t provide an audit trail that would let you detect if a programming mistake, a duplicate form submission, or nefarious activity changed a value. You should instead insert a new row in a related/child table for every transaction that affects a value. Doing this will also let you easily determine if there is a streak of x events.

I reviewed your previous threads on the forum, mainly to see if they provided some insight as to what you are trying to do in this thread, since a tail-end snippet of code doesn’t really help us to help you with why something on your page doesn’t work.

I/we are not are not trying to give you a hard time or needlessly cause you more work through the suggestions that have been made. The suggestions have been to produce code that’s -

  1. Secure. It also turns out that using a prepared query, with the PDO extension, simplifies the php code and simplifies the sql query syntax.
  2. Provides a good User eXperience (UX.) The user will know what they should do and if something they did caused an error that they can correct by resubmitting data.
  3. Simple, general purpose, and reusable. The code you have shown is filled with a wall of unnecessary things that don’t add any value and have ignored the suggestions that have been made, so that we are repeating the same suggestions over and over.
  4. Will either work or it will tell you (display/log) the reason why it won’t.
Sponsor our Newsletter | Privacy Policy | Terms of Service