Es kommt immer NULL zurück,
Dann ist wohl etwas falsch mit dem Query...
Probiers mal so:
PHP
<?php
header('Content-Type: text/json');
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'globalban');
define('DB_PASSWORD', 'globalban');
define('DB_NAME', 'globalban');
$dbh = null;
try {
$dbh = new PDO('mysql:host='.DB_SERVER.';dbname='.DB_NAME, DB_USERNAME, DB_PASSWORD);
if($dbh === true) {
foreach ($dbh->query('SELECT * globalban') as $row) {
print_r($row);
}
}
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . '<br/>';
die();
}
// Wenn kein Eintrag vorhanden ist
if(!isset($_GET['ip'], $_GET['playerLicense'])) //usw...
{
$json = array(
[
'status' => 'Ok',
],
);
echo json_encode($json);
exit;
}
$ip = $_GET['ip'];
$playerLicense = $_GET['playerLicense'];
$playerSteam = $_GET['playerSteam'];
$playerXbl = $_GET['playerXbl'];
$playerLive = $_GET['playerLive'];
$playerDisc = $_GET['playerDisc'];
//Wenn Parameter übergeben werden
if(!empty($ip) && !empty($playerLicense) && !empty($playerSteam) && !empty($playerXbl) && !empty($playerLive) && !empty($playerDisc)) {
$sth = $dbh->prepare("SELECT * FROM `globalban` WHERE `ip`=? AND `playerLicense`=? AND `playerSteam`=? AND `playerXbl`=? AND `playerLive`=? AND `playerDisc`=? LIMIT 1");
$sth->execute(array($ip,$playerLicense,$playerSteam,$playerXbl,$playerLive,$playerDisc));
$row = $sth->fetch(PDO::FETCH_OBJ);
print_r($row); //Gib dir das doch mal aus, was steht da denn drinnen?!
$json = array(
'status' => 'Found',
'result' => [
'ip' => 'Redacted',
'License Hash' => $row->playerLicense,
'Steam ID' => $row->playerSteam,
'XBox Live ID' => $row->playerXbl,
'Live ID' => $row->playerLive,
'Discord ID' => $row->playerDisc,
],
'reason' => [
'Ban Reason' => $row->banReason,
],
);
echo json_encode($json);
//Wenn Parameter Leer sind
} else {
$json = array(
[
'error' => 'Only PostRequest Allowed :(',
],
);
echo json_encode($json);
}
Alles anzeigen