Odd character in Flex, PHP, and JSON

December 16, 2009 on 12:30 pm | In PHP, Rich Internet Applications, flex | No Comments

Been busy as all get out these days. Seems like since it is the holidays, things would be slow. Guess this is a good thing. I  have been working on a Flex project using JSON and PHP. Basically, I am using httpService to get data from MySQL using the PHP JSON functions. Fairly straight forward stuff.

I had used this setup in a previous project so the code was already setup. I had my method set to POST in the flex service and was getting the data just fine. All was good until i tried to decode with JSON.decode(). I kept getting this parsing error on a single character. This was the same code I used before, with very minor changes.

I checked up and down trying to figure out what got screwed up. My returned JSON string appeared to be valid. I ran it through the validator and it was fine. Turns out that a question mark was being returned by PHP as the first character of the JSON string. Not very obvious to see just echoing the JSON string to the screen on the PHP side. I ended up processing the string to remove the character before decoding it, but I still don’t know why the question mark shows up in this project and not the previous one.  Very odd.

DCF

Flex HTTPService and IE

October 14, 2009 on 12:44 pm | In PHP, Rich Internet Applications, flex | No Comments

I recently had a weird problem with working with HTTPService for Flex. I had been using the Flex RemoteObject along with ZendAMF which was working fine until I recently upgraded and could not for the life of me get everything set up correctly. From what I understand, I guess something got messed up in the packaging of the recent release. I figured I would go back to it later once they got that all sorted out.

Since the data I was pulling was fairly light, I figured it might now be a good time to check out JSON in Flex. Got evertything working just fine, and was able to get records from the database fairly easily. Then I started inserting and updating records and thats when it got weird. Aparently, there is a caching issue with Internet Exlporer (IE).  I was using GET as my transfer method and it turns out that subsequent GETs are cached in IE, so if you try to update your table, you get the same data until you restart the app. Could drive one mad. Firefox does not have this issuse. Once I switched to POST as my method, all went well. Thank God for folks who post these quirks!

Flex HTTPService, Browser Cache and IE

Using Flex, PHP, and JSON to Modify a MySQL Database

D

Zend AMF

March 5, 2009 on 5:22 pm | In PHP, Rich Internet Applications, Windows, flex, tools | No Comments

In the past, I’ve used AMFPHP for my Flash/PHP remoting. Wade Arnold, the developer of AMFPHP has also been working with Zend and set up ZendAMF. I figured since Adobe is supporing it, it would probably be a good idea to get used to using it. I needed to quickly get up to speed on how to use it. There are a few really good tutorials out there. Lee Brimelow has a good one on his site that gives a good introduction. Mihai Corlan has a good one as well.

The tutorial that really helped me out the most was this two parter created by Richard Bates. I needed to understand how to integrate ZendAMF and Flex, and his tutorial explains it very well. Enjoy.


Getting Started with Zend AMF (Zend_Amf) - Part One from richard bates on Vimeo.

Also Check out the Zend Framework, which is a wealth of PHP goodness.

-DCF

PHP Command Line Interface

February 13, 2009 on 11:09 am | In PHP, Windows, open source, tools | No Comments

I use PHP as my website scripting language of choice. I also work between both Windows and Linux, spending a good deal of time in Windows for design activities. I swear if Adobe made Linux versions of everything, I probably would ditch Windows altogether as I am coming to enjoy Ubuntu Linux quite a bit.

There are times when I need to do command line stuff in Windows that I can easily do in Linux with a script, but can’t do in Windows. Windows has a batch language that is good for simple things, but it often does not fulfill the need.
Case in point, I needed to be able to quickly find in some text based data files a particular string of data. Once found, I needed to be able to move those files to a separate folder. Once moved, I needed to be able to extract data from those files, and load that data into a database. Sure I could do it in C++ or C#, or even pull the whole shebang over to Linux and process there, but why bother when I got good ol’ PHP that can be executed from the command line right in Windows.

PHP supports a SAPI (Server Application Programming Interface) called CLI (Command Line Interface). With PHP, I was able to write a few scripts that quickly did exactly what I needed. They execute from the command line, and even runs DOS commands for file management using the shell_exec() function. One can even make desktop applications with it, and the CLI works on Linux as well. Using PHP’s CLI is simply a really nice way to automate system administration task in Windows.

Using PHP from the command line

-DCF

Entries and comments feeds. Valid XHTML and CSS. ^Top^ Powered by WordPress