Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- header("Content-type: text/plain");
- error_reporting(0);
- $host = 'localhost'; //put your host here
- $user = 'space'; //in general is root
- $password = 'space'; //use your password here
- $dbname = 'space'; //your database
- mysql_connect($host, $user, $password) or die("Cant connect into database");
- mysql_select_db($dbname)or die("Cant connect into database");
- if ($_REQUEST["sector"] <> "") {
- $selcmd = "SELECT * FROM planets where sector='".$_REQUEST["sector"]."'";
- $result = mysql_query($selcmd) or die (mysql_error());
- while($row = mysql_fetch_array( $result )) {
- if ($row['ID'] > 0) {
- if ($row['guid'] > 0) {
- $xselcmd = "SELECT Username FROM account where ID='".$row['guid']."'";
- $xresult = mysql_query($xselcmd) or die (mysql_error());
- while($xrow = mysql_fetch_array( $xresult )) {
- // echo "".$xrow['Username'].",";
- $username=$xrow['Username'];
- }
- } else {
- //echo ",";
- $username="";
- }
- $arr = array (
- 'ID'=>$row['ID'],
- 'x'=>$row['x'],
- 'y'=>$row['y'],
- 'z'=>$row['z'],
- 'Username'=>$username,
- 'sector'=>$row['sector'],
- 'name'=>$row['name'],
- 'type'=>$row['type']);
- echo json_encode($arr);
- }
- }
- exit;
- }
- if ($_REQUEST["planet"] > 0) {
- $selcmd = "SELECT * FROM resourcedata where guid='".$_REQUEST["planet"]."'";
- $result = mysql_query($selcmd) or die (mysql_error());
- while($row = mysql_fetch_array( $result )) {
- if ($row['ID'] > 0) {
- $arr = array (
- 'restype'=>$row['restype'],
- 'ResourceCount'=>$row['ResourceCount']);
- echo json_encode($arr);
- // echo $row['restype'].",";
- // echo $row['ResourceCount']."\n";
- }
- }
- exit;
- }
- if ($_REQUEST["restypes"] <> "") {
- $selcmd = "SELECT * FROM restypes";
- $result = mysql_query($selcmd) or die (mysql_error());
- while($row = mysql_fetch_array( $result )) {
- if ($row['ID'] > 0) {
- $arr = array (
- 'ID'=>$row['ID'],
- 'Type'=>$row['Type'],
- 'resType'=>$row['resType']);
- echo json_encode($arr);
- // echo $row['ID'].",";
- // echo $row['Type'].",";
- // echo $row['resType']."\n";
- }
- }
- exit;
- }
- // Close mySQL Connection
- mysql_close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement