<?php
// Anfang
include("cnf/var.php");
// Ende
$conn = new mysqli($dbhost,$dbusername,$dbpassword,$dbname);
$query = file_get_contents("php://input");
if (mysqli_errno()) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysqli_error();
}
else
{
$result = $conn->query($query);
if (isset($_GET["select"]))
{
$rows = array();
while($r = $result->fetch_assoc()) {
$rows[] = $r;
}
print json_encode($rows);
}
elseif (isset($_GET["insert"]))
{
print $conn->insert_id;
}
else
{
print $sth;
}
}
?>