Advertisement
Gayngel

ReRoll_Lottery_Draw

Apr 5th, 2023 (edited)
1,415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <?php
  2.  
  3.  $host = "localhost";
  4.  $username = "id20395489_rum_lot";
  5.  $password = ")X1Z^w^Y+XG8Ob/6";
  6.  $dbname = "id20395489_lottery";
  7.  
  8.  
  9.  try {
  10.     $conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
  11.     // set the PDO error mode to exception
  12.     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  13.    
  14.    
  15.    
  16.    
  17.    
  18.     //$query = $conn->prepare("SELECT `uuid` FROM `lottery_db` WHERE `uuid` = '".$uuid."'");
  19.     //$query->execute();    
  20.     //$result = $query->fetch(\PDO::FETCH_ASSOC);
  21.     //echo json_encode($result);
  22.    
  23.     //echo "\n\n";
  24.    
  25.     //$rand = $conn->prepare("SELECT `uuid` FROM `lottery_db` ORDER BY RAND() LIMIT 3");
  26.    // $rand->execute();
  27.    // $rresult = $rand->fetchALL(\PDO::FETCH_ASSOC); // when getting multiple rows use fetchALL
  28.    // echo json_encode($rresult);
  29.    
  30.    // echo "\n\n";
  31.    
  32.    // $rand = $conn->prepare("SELECT `uuid`, `timestamp` FROM `lottery_db` WHERE TIMESTAMPDIFF(day,`timestamp`,'".$date."' ) < 7  ORDER BY RAND() LIMIT 3");
  33.    // $rand->execute();
  34.    // $rresult = $rand->fetchALL(\PDO::FETCH_ASSOC); // when getting multiple rows use fetchALL
  35.    // echo json_encode($rresult);
  36.    
  37.     $date = date_create('now', timezone_open('America/Los_Angeles'));
  38.     $date = date_format($date, 'Y-m-d H:i:s');
  39.    
  40.    
  41.     $incr = $conn->prepare("
  42.    UPDATE `lottery_db`
  43.    SET `wins` = `wins` + 1
  44.    WHERE TIMESTAMPDIFF(day,`timestamp`,'".$date."' ) < 14 AND `wins` < 3
  45.    ORDER BY RAND()
  46.    LIMIT 3");
  47.      $incr->execute();
  48.      
  49.     }
  50.    
  51.    
  52.    
  53.    
  54.      catch(PDOException $e) {    
  55.     echo "Connection failed: " . $e->getMessage();
  56.     }
  57.  
  58.  
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement