I'm back with another question.
I'm trying to create a JSON file that gets data from my MySQL database. The thing is, I'm getting the '500 Internal Server Error' message.
The Code:
<?php
header('Content-Type: application/json');
if (!isset($_GET['query'])) {
echo json_encode([]);
exit();
}
$db = new PDO('mysql:host=127.0.0.1;dbname=mydbname', 'mydbuser', 'mydbpaswd');
$users = $db->prepare("SELECT id, username FROM users WHERE username LIKE :query");
$users->execute(['query' => "{$_GET['query']}%"]);
echo json_encode($users->fetchAll());
?>
I typed in http://mylink.com/users.php?query=ch this should have given me a page with possible usernames starting with 'ch'.
P.S. I used basic names for some things to not show my actual names.
Thanks, in advance.