Jump to content
MakeWebGames

Problem with code


Recommended Posts

Hello MWG! I have a slight problem. So the Mugger of the hour Sniko made whenever someone mugs someone a new insert in the table happens instead of updating the table.

Even if there is already a table for the user?

[ATTACH=CONFIG]1782[/ATTACH]

Code -

$objThisHour = $db->query("SELECT `uid` 
                      FROM `mugger_oth`
                      WHERE `uid` = ". $userid ."
                        AND `date_start` LIKE DATE_FORMAT(NOW(), '%Y-%m-%d %k')");
       if($db->num_rows($objThisHour) > 0) {
           $db->query("UPDATE `mugger_oth` 
                          SET `total_mugged` = `total_mugged` + ". $stole .",
                              `total_mugs` = `total_mugs` + 1
                          WHERE `uid` = ". $userid ."
                            AND `date_start` LIKE DATE_FORMAT(NOW(), '%Y-%m-%d %k')");

       } else {
           $db->query("INSERT INTO `mugger_oth` (`uid`,`total_mugged`,`date_start`, `total_mugs`) VALUES (". $userid .", ". $stole .", NOW(), 1)");

       }

290693613_ScreenShot2015-01-06at18_54_00.png.606540a37e08cad95483aea45aa8972b.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...