Why my code doesn´t works?. I have another one with the same code and it works!. I dont know what´s the problem with this one.
<?php
include("../conexion.php");
if($_SERVER['REQUEST_METHOD'] == 'GET')
{
$query = 'SELECT Id, Nombre, Descripcion FROM empresa ORDER BY Nombre';
$sql = mysql_query($query, $link);
mysql_close($link);
while($row = mysql_fetch_array($sql, MYSQL_ASSOC)){
$myEnterprises[] = array(
'Id' => $row['Id'],
'Nombre' => $row['Nombre'],
'Descripcion' => $row['Descripcion']);
}
$myData = array('myEnterprises' => $myEnterprises);
echo json_encode($myData);
}
?>
(PHP 5 >= 5.2.0, PECL json >= 1.2.0)
json_encode — Returns the JSON representation of a value
This is the minimum requirement for running json_encode() in your server. Check your PHP version. If the PHP version is less than 5.2.0 ,follow this link for implementation of json_encode in your server / php application .