I'm trying to generate a JSON file, but I'm getting ERROR 2, when I try to connect to the BD, my hosting uses PHP7, I do not know if that is influencing the error, before it worked correctly.
ERROR:
Opps some thing went ERROR 2
PHP File
<?php
error_reporting(0);
$hostname = "host";
$user = "user";
$password = "****";
$database = "BD";
$db = mysqli_connect($hostname, $user, $password) or die("Opps some thing went wrong");
mysqli_select_db($database, $db) or die("Opps some thing went ERROR 2");
// array for JSON response
$response = array();
// get all items from myorder table
$result = mysqli_query("SELECT * FROM escolar_tracker ") or die(mysqli_error());
if (mysqli_num_rows($result) > 0) {
$response["rutas"] = array();
while ($row = mysqli_fetch_array($result)) {
// temp user array
$item = array();
$item["id"] = $row["id"];
$item["ruta"] = $row["ruta"];
$item["jornada"] = $row["jornada"];
// push ordered items into response array
array_push($response["rutas"], $item);
}
// success
$response["success"] = 1;
}
else {
// order is empty
$response["success"] = 0;
$response["message"] = "No Items Found";
}
// echoing JSON response
echo json_encode($response);
?>