FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Json result
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Json result [message #175722 is a reply to message #175720] Sat, 22 October 2011 19:39 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  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
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Import values reading from XML nodes
Next Topic: PHP Extension Namespaces
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 17:20:54 GMT 2024

Total time taken to generate the page: 0.04905 seconds