<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
	//echo nl2br("Entering the PHP\r\n");
	//$query=$_COOKIE["Query"];
	//$query=filter_input(INPUT_POST, 'data1');
	$query="";
	if(isset($_GET['data1'])){
	$query=$_GET['data1'];
	}
		  /*print_r($query);
		  echo nl2br("\r\n");*/

	//$Pays=$_COOKIE["Pays"];
	$TMP=[];
	$dbhost = "localhost"; /*most of the time it's localhost*/
    $username = "roph1153_Plan";
    $password = "Veap-stFp-76M}";
    $dbname = "roph1153_Planning";
    $password = "Veap-stFp-76M}";
	$mysql = mysqli_connect($dbhost, $username, $password, $dbname); //It connects
	/* 1️⃣  Parle UTF-8 *avant* toute requête */
    mysqli_set_charset($mysql, 'utf8mb4');   // ou  SET NAMES utf8mb4
	if($mysql === false){
	  die("ERROR: Could not connect. " . mysqli_connect_error());
	  print_r($mysql);
	}
	if($result=mysqli_query($mysql, $query)){
		  /*print_r($result);
		  echo nl2br("\r\n");*/
	  while ($row2 = mysqli_fetch_row($result)) {
		  array_push($TMP,$row2);
          }
	  //echo json_encode($TMP);
	  header('Content-Type: application/json; charset=utf-8');
        echo json_encode($TMP, JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE);
 
		} else {
	  echo "ERROR: Could not able to execute $query. " . mysqli_error($mysql);
	  
	}
	mysqli_close($mysql);

?>
