Jump to content

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?


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)");



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.

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...