I am trying to convert my PHP array that i get as a query result to a JSON array. But look like it does not work. Any help would be appriciated.
$stmt = $db->prepare("SELECT * FROM companies WHERE companyID = ?");
if($stmt == "false"){
die('Query error !'.$db->error);
}
$stmt->bind_param('i', $companyID);
$stmt->execute();
$result = $stmt -> get_result();
$companies = $result ->fetch_all(MYSQLI_BOTH);
echo json_encode(array('companies' => $companies));
But look like it does not work.please be even less specific if possible$result ->fetch_allactually give you an array or just something array-like?echo json_encode(array('companies' => $companies));?