Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

On my server I have a php script that calculated an amount for in game money, but the SELECT and UPDATE query are not doing the right thing.

In my database I have two columns:

| Name         | Now | Added | Taken | Time                      |
- This Minute  | 0   | 0     | 0     | [date is here]
- Last Minute  | 10  | 10    | 0     | [before updated date here]

every time the script runs it is supposed to update the this minute info with the last minute info, but its not.

This is what im trying

date_default_timezone_set('Australia/Perth');
$date = date('H:i:s'); // get time
$dateInt = str_replace(':',' ', $date);
$dateInt = explode(" ", $dateInt);

$sqlT = "SELECT * FROM Calc WHERE Name= 'Last Minute'";
$sql = "UPDATE Calc SET Time='$date' WHERE Name='This Minute'";

$result = mysql_query($sql,$conn);
$resultT = mysql_query($sqlT,$conn);

while($row = mysql_fetch_assoc($resultT)) {
    $Ttime = $row['Time']; // gets the time from the server
    $taken = $row['Ever Taken'];
    $added = $row['Ever Added'];
    $nowOld = $row['Now'];
}

$Ttime = str_replace(':',' ', $Ttime);
$Ttime = explode(" ", $Ttime);

if($dateInt[1] >= $Ttime[1])
{
    echo "\n<br/>Need to update time!";
    echo "\n<br/>Updating old stats with new ones!";
    $update = "UPDATE Calc SET Now=$nowOld AND 'Ever Taken'=$taken AND 'Ever added' =$added  WHERE Name='This Minute'";
    $updateT = "UPDATE Calc SET Time=Date WHERE Name='Last Minute'";
    $fine = mysql_query($update,$conn);
    $fineT = mysql_query($updateT,$conn);
    if(! $fine && ! $fineT)
    {
        die('\n<br/>Could not update data: ' . mysql_error());
    }
    echo "\n <br/> Updated stuff successfully\n";
}

the problem is that its not updating the information correctly.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.