Home »
Imported messages »
comp.lang.php »
Json result
Re: Json result [message #175722 is a reply to message #175720] |
Sat, 22 October 2011 19:39 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 10/22/2011 3:02 PM, Sarah wrote:
> Hi! I had a page for generate an XML file, now I'm trying to change it
> for return JSON file
>
> in $result I've my query
>
> while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
>
> $data['locations'][] = $row;
> }
>
> Header('Content-type: application/json');
> echo json_encode($data);
> exit;
>
>
> When I try to exevcute this page browser ask me to download the page
> and if I insert
>
> echo '----';
> print_r($data['locations']);
> print_r($data);
> die;
> Header('Content-type: application/json');
> echo json_encode($data);
> exit;
>
>
> I show only '---'
>
> Can you help me??
>
> Thanks
It would be normal for the browser to ask if you wanted to download the
file. The browser doesn't know how to handle a file of type
application/json.
As for your results - what do you see when you look at the page source?
Enable all errors and display them to see if you have any. In the
php.ini file on your development system, put:
error_reporting=E_ALL
display_errors=on
See if you get any errors (you should have this in your development
system anyway).
If you don't see any errors, your query just returned no data and the
page source just contains the '---', then your query is just returning
no data.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Goto Forum:
Current Time: Sun Nov 10 05:55:09 GMT 2024
Total time taken to generate the page: 0.03858 seconds