Advertisement
Guest User

MySQL SteamID

a guest
Oct 17th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. <?php
  2.  
  3.     // MYSQL DATABASE STUFF
  4.  
  5.     $testuser = "FlappyBlubber";
  6.    
  7.     $testuserid = "1232131"; // steam id
  8.  
  9.     $server = "localhost";
  10.    
  11.     $user = "root";
  12.    
  13.     $pass = "";
  14.    
  15.     $db = "csgodemise";
  16.  
  17.     $conn = mysqli_connect($server, $user, $pass, $db);
  18.    
  19.     if(!$conn) {
  20.        
  21.         die("Could not connect to MySQL!");
  22.        
  23.     }
  24.    
  25.     $sql = "SELECT * FROM players WHERE steamid = '$testuserid'"; // gets everything (name, id, coins, steamid) from row in table where id = 1
  26.    
  27.     $result = mysqli_query($conn, $sql);
  28.    
  29.     $count = mysqli_num_rows($result);
  30.    
  31.     if($count == 0) {
  32.        
  33.         die("User does not exist!");
  34.        
  35.     } else {
  36.        
  37.         foreach($result as $row) {
  38.            
  39.             $name = $row["name"]; // gets the name from the row
  40.            
  41.             $coins = $row["coins"]; // gets coins from the row
  42.            
  43.         }
  44.        
  45.     }
  46.  
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement