mysql problem (can you help?)

Discussion in 'MySQL' started by lowridertj, Jan 25, 2009.

  1. #1
    So I have a table that is updated by cron to decrease the number set in the table.

    
    <?php
    
      `attin` int(10) unsigned NOT NULL default '0',
    
    ?>
    
    PHP:
    now my cron would decrease this number every hour with the following code.

    
    <?php
    
    function fetch ($query)
    {
    	$data = mysql_fetch_row(mysql_query($query));
    	return $data[0];
    }
    $getgames = mysql_query("SELECT round,attin,attout,attindown,attoutdown FROM $tab[game] WHERE starts<$time AND ends>$time ORDER BY round ASC;");
    while ($game = mysql_fetch_array($getgames))
    {
    
    $downin = $game[1]-1;
    
    mysql_query("UPDATE r$game[0]_$tab[pimp] SET attin='$downin' WHERE id>0 AND attin>'$game[1]';");
    mysql_query("UPDATE r$game[0]_$tab[pimp] SET attin='0' WHERE id>0 AND attin<='$game[1]';");
    mysql_query("UPDATE r$game[0]_$tab[pimp] SET attout=attout-$game[4] WHERE id>0 AND attout>'$game[4]';");
    mysql_query("UPDATE r$game[0]_$tab[pimp] SET attout='0' WHERE id>0 AND attout<='$game[4]';");
    mysql_query("UPDATE r$game[0]_$tab[pimp] SET attout='0' WHERE id>0 AND attout>'1000000';");
    
    
    }
    
    ?>
    
    PHP:
    When it runs it seems as though it is making them max out the largest possible number on " attin " when it goes below 0 How can I fix this or stop it from happening.

    Thanks,
    TJ
     
    lowridertj, Jan 25, 2009 IP
  2. cody4camp

    cody4camp Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you could try doing it as integer?
     
    cody4camp, Jan 25, 2009 IP
  3. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #3
    the table is setup as int.

    and being set as unsigned means it should go from 0 - and up.
    stead of allowing negatives.

    But what it is doing is if it trys taking more then what they have for attin then it takes it and goes to the largest number possible for the int 10
     
    lowridertj, Jan 25, 2009 IP
  4. cody4camp

    cody4camp Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    this looks like the my pimp script base(variables and such) is it?
     
    cody4camp, Jan 25, 2009 IP
  5. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #5
    originally way back when yes. I resell it as a mafia script compeltely reformatted but a client made changes to his and is having this issue.

    world hatred was the originator of the pimp version.

    TJ
     
    lowridertj, Jan 25, 2009 IP