Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #3503

Re: Json result

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: Json result
Date 2011-10-22 15:39 -0400
Organization A noiseless patient Spider
Message-ID <j7v651$kaf$1@dont-email.me> (permalink)
References <1f16f160-c518-4ff2-8851-d3131c600be5@j20g2000vby.googlegroups.com>

Show all headers | View raw


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@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Json result Sarah <dandi.box@gmail.com> - 2011-10-22 12:02 -0700
  Re: Json result Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-22 15:39 -0400
    Re: Json result Sarah <dandi.box@gmail.com> - 2011-10-22 14:16 -0700
      Re: Json result Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-22 17:22 -0400

csiph-web