<?php
$databasehost = "localhost";
$databasename = "asc202304";
$databaseusername ="root";
$databasepassword = "xxxxxxxx";
$con = mysqli_connect($databasehost,$databaseusername,$databasepassword, $databasename) or die(mysqli_error($con));
mysqli_set_charset ($con , "utf8");
$query = file_get_contents("php://input");
$sth = mysqli_query($con, "SET SESSION GROUP_CONCAT_MAX_LEN =1000000");
//you can set the query by adding the query parameter For ex: http://127.0.0.1/test.aspx?query=select * from table1
$sth = mysqli_query($con, $query);
if (mysqli_errno($con)) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysqli_error($con);
}
else
{
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
$rows[] = $r;
}
$res = json_encode($rows);
echo $res;
mysqli_free_result($sth);
}
mysqli_close($con);
?>