You can’t use GET nor POST on a free domain. Rest api on free hosting? - Hosting Support - InfinityFree Forum
oh. can you reccomend any alternatives?
Github Pages or Trello.
trello stopped supporting it too a long time ago
for github, how will I set this up? I already have a php script that fetches from my database
Trello API [ReMade] • Use Trello easily in your game! Again you can just use github pages if you wanna.
so I can still use my php script to transmit the data to the github page?
Which php script are you using and why? All I am seeing that you’re trying to do is a simple ban list.
It queries my sql database and transmits it into a readable json format
Not sure why you would need php for that since roblox already decodes json for you?
no, my sql isnt readable so i format it, check the site
It does seem readable to me, just a bunch of userids.
Yes, because I had to format it.
for my database, I use a sql myphp
// Database connection variables
$servername = "";
$username = "";
$password = "";
$dbname = "";
// Create database connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Process incoming POST request to add new player data
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Retrieve and decode the JSON payload from the request body
$postData = json_decode(file_get_contents('php://input'), true);
// Check for errors in decoding JSON
if (json_last_error() !== JSON_ERROR_NONE) {
http_response_code(400); // Bad Request
echo json_encode("Invalid request data");
exit;
}
// Extract player data from decoded payload
$newUserId = $postData["UserId"];
// SQL query to add new player data
$sql = "INSERT INTO players (UserId) VALUES ('$newUserId')";
// Execute SQL query
if ($conn->query($sql) === TRUE) {
http_response_code(201); // Created
echo json_encode("New player data added successfully");
} else {
http_response_code(500); // Internal Server Error
echo json_encode("Error adding new player data: " . $conn->error);
}
exit;
}
// SQL query to retrieve data
$sql = "SELECT `UserId` FROM `players` WHERE 1";
$result = $conn->query($sql);
// Check for errors
if (!$result) {
die("Query failed: " . $conn->error);
}
// Output data as a JSON page
header('Content-Type: application/json');
if ($result->num_rows > 0) {
$data = array();
while($row = $result->fetch_assoc()) {
$data[] = array("UserId" => (int)$row["UserId"]);
}
echo json_encode($data);
} else {
echo json_encode("0 results");
}
?>
Can’t you just use a pre-formatted version? why would you need to reformat it? Besides, you can use that in github pages if you wanna.
cant reform it, my sql database makes the json [(thing,thing)] and not [{“Thing”:thing}]
please tell me how I implement this into github
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.