Advertisement
Guest User

Untitled

a guest
Jun 16th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. <?
  2. header("Content-type: text/plain");
  3. error_reporting(0);
  4. $host = 'localhost'; //put your host here
  5. $user = 'space'; //in general is root
  6. $password = 'space'; //use your password here
  7. $dbname = 'space'; //your database
  8.  
  9. mysql_connect($host, $user, $password) or die("Cant connect into database");
  10. mysql_select_db($dbname)or die("Cant connect into database");
  11.  
  12. if ($_REQUEST["sector"] <> "") {
  13. $selcmd = "SELECT * FROM planets where sector='".$_REQUEST["sector"]."'";
  14. $result = mysql_query($selcmd) or die (mysql_error());
  15.  
  16. while($row = mysql_fetch_array( $result )) {
  17. if ($row['ID'] > 0) {
  18. if ($row['guid'] > 0) {
  19. $xselcmd = "SELECT Username FROM account where ID='".$row['guid']."'";
  20. $xresult = mysql_query($xselcmd) or die (mysql_error());
  21. while($xrow = mysql_fetch_array( $xresult )) {
  22. // echo "".$xrow['Username'].",";
  23. $username=$xrow['Username'];
  24. }
  25.  
  26. } else {
  27. //echo ",";
  28. $username="";
  29. }
  30. $arr = array (
  31. 'ID'=>$row['ID'],
  32. 'x'=>$row['x'],
  33. 'y'=>$row['y'],
  34. 'z'=>$row['z'],
  35. 'Username'=>$username,
  36. 'sector'=>$row['sector'],
  37. 'name'=>$row['name'],
  38. 'type'=>$row['type']);
  39.  
  40. echo json_encode($arr);
  41. }
  42. }
  43.  
  44. exit;
  45. }
  46.  
  47. if ($_REQUEST["planet"] > 0) {
  48. $selcmd = "SELECT * FROM resourcedata where guid='".$_REQUEST["planet"]."'";
  49. $result = mysql_query($selcmd) or die (mysql_error());
  50.  
  51. while($row = mysql_fetch_array( $result )) {
  52. if ($row['ID'] > 0) {
  53. $arr = array (
  54. 'restype'=>$row['restype'],
  55. 'ResourceCount'=>$row['ResourceCount']);
  56. echo json_encode($arr);
  57.  
  58.  
  59. // echo $row['restype'].",";
  60. // echo $row['ResourceCount']."\n";
  61. }
  62. }
  63.  
  64. exit;
  65. }
  66.  
  67. if ($_REQUEST["restypes"] <> "") {
  68. $selcmd = "SELECT * FROM restypes";
  69. $result = mysql_query($selcmd) or die (mysql_error());
  70.  
  71. while($row = mysql_fetch_array( $result )) {
  72. if ($row['ID'] > 0) {
  73.  
  74. $arr = array (
  75. 'ID'=>$row['ID'],
  76. 'Type'=>$row['Type'],
  77. 'resType'=>$row['resType']);
  78. echo json_encode($arr);
  79.  
  80. // echo $row['ID'].",";
  81. // echo $row['Type'].",";
  82. // echo $row['resType']."\n";
  83. }
  84. }
  85.  
  86. exit;
  87. }
  88.  
  89. // Close mySQL Connection
  90. mysql_close();
  91. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement