SHARE
TWEET

Untitled

a guest May 31st, 2017 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $server = "";
  3. $username = "";
  4. $password = "";
  5. $database = "";
  6. mysql_connect($server,$username,$password) or die("Failed");
  7. mysql_select_db($database) or die("Database Failed");
  8.  
  9. $url = "";
  10. $string = file_get_contents($url);
  11. var_dump($string);
  12. $arr = json_decode($string, true);
  13. var_dump($arr);
  14.  
  15. foreach($arr as $data){
  16.   echo("Foreach Loop\n");
  17.   var_dump($data);
  18.   $clusterkey = isset($data['ClusterKey']) ? $data['ClusterKey'] : '';
  19.   $steamid = isset($data['SteamId']) ? $data['SteamId'] : '';
  20.   $charactername = isset($data['CharacterName']) ? $data['CharacterName'] : '';
  21.   $gender = isset($data['Gender']) ? $data['Gender'] : '';
  22.   $tribename = isset($data['TribeName']) ? $data['TribeName'] : '';
  23.   $tribeid = isset($data['TribeId']) ? $data['TribeId'] : '';
  24.   $level = isset($data['Level']) ? $data['Level'] : '';
  25.   $engrampoints = isset($data['EngramPoints']) ? $data['EngramPoints'] : '';
  26.   $latitude = isset($data['Longitude']) ? $data['Latitude'] : '';
  27.   $longitude = isset($data['Longitude']) ? $data['Longitude'] : '';
  28.   $topomapx = isset($data['TopoMapX']) ? $data['TopoMapX'] : '';
  29.   $topomapy = isset($data['TopoMapY']) ? $data['TopoMapY'] : '';
  30.   $savedat = isset($data['SavedAt']) ? $data['SavedAt'] : '';
  31.  
  32.   $sql = "INSERT INTO players(clusterkey, steamid, charactername, gender, tribename, tribeid, level, engrampoints, latitude, longitude, topomapx, topomapy, savedat)
  33. VALUES('$clusterkey', '$steamid', '$charactername', '$gender', '$tribename', '$tribeid', '$level', '$engrampoints', '$latitude', '$longitude', '$topomapx', '$topomapy', '$savedat');";
  34.  
  35.   echo("SQL String\n");
  36.   echo($sql."\n");
  37.  
  38.   if(!mysql_query($sql)){
  39.     die('Error : ' . mysql_error());
  40.   }
  41. }
  42. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top