Showing posts with label json. Show all posts
Showing posts with label json. Show all posts

Thursday, August 23, 2007

Development environment in Linux

So getting my development environment set up in linux was no small task. I'm using Fedora 6. Here were some of the obstacles:

1) The distribution's version of Firefox doesn't come compiled with the necessary debug flags for Firebug to work properly. I downloaded a new version of Firefox directly from the website and that seemed to have solved most of the debug problems. I've heard that you may need to download the source and compile it by hand with some special flags, but luckily the downloaded tarball worked for me.

2) The php-json package was missing from my installation of php. A simple yum install fixed that problem.

Tuesday, August 7, 2007

JSON, php, and html forms

So I've been working on a data processing page that is hidden from the user, takes form data from an input page, processes the data, encodes the data using json in a new form, then auto submits the form to a new page. Here are a few helpful functions that got it working properly:

1. The json_encode() function in php doesn't escape some html special characters like quotes. It's helpful to wrap it with the function htmlspecialchars() so that it plays nice with your html.

2. php line breaks are '\r'. I had inadvertently included some line breaks in my string variables. To fix that problem use the trim() function.