Kod:
<?php
// get the HTTP method, path and body of the request
$method = $_SERVER['REQUEST_METHOD'];
$request = explode('/', trim($_SERVER['PATH_INFO']));
$input = json_decode(file_get_contents('php://input'),true);
// connect to the mysql database
$link = mysqli_connect('', '', '', 'remakenetwork');
mysqli_set_charset($link,'utf8');
// retrieve the table and key from the path
$key = array_shift($request);
// create SQL based on HTTP method
switch ($method) {
case 'GET':
$sql = "select * from `users`".($key?" WHERE username=$key":'');
break;
}
// excecute SQL statement
$result = mysqli_query($link,$sql);
// print results, insert id or affected row count
if ($method == 'GET') {
if (!$key) echo '[';
echo json_encode(mysqli_fetch_object($result));
if (!$key) echo ']';
} elseif ($method == 'POST') {
echo mysqli_insert_id($link);
} else {
echo mysqli_affected_rows($link);
}
// close mysql connection
mysqli_close($link);
Koddaki hata nerede acaba? çalışmıyor
return olarak ise
Kod:
[{"id":"1","username":"MargeSimpson","country":"Brazil","password":"MargeSimpson","created_at":null,"ip_address":null,"game_token":"MargeSimpson","city":null,"ban":"0"}]