Flash Builder/Flex 4 and ZendAMF alternative connection example

I was attempting to try out a simple test of ZendAMF and Flash Builder. I had begun by building the test using WAMP on my local machine. I began by using the built in Connect to Data/Service Wizard built into Flash Builder.  The example I was following was from an article over at the Zend Developer Zone called: Data-centric Adobe Flash Builder development with the Zend Framework. Everything worked slick as can be running locally on WAMP but when I tried using the same data connection with my site on my hosting company, I was ending up with errors due to the age of mySQL and PHP that my host is currently using. I am still working on resolving those problems. But in the meantime I was needing to get it to work.  I decided to incorporate the simple example Lee Brimelow used with his Flash and Zend AMF tutorial.

The example here is a simple voting screen to pick from a set of actors for best actor and worst actor. It holds a simple SharedObject variable to determine if you have already voted and keeps you from voting twice.


Here is the awards.php file:

class awards {
public function __construct()
require("/*path to file outside of public web directory*/configConn.inc.php");
mysql_select_db("/*my database*/" );
public function getPeople()
$result = mysql_query("SELECT * FROM awards");
$t = array();

while($row = mysql_fetch_assoc($result))
array_push($t, $row);

return $t;


public function add( $bestActor, $worstActor ) {

$insert = sprintf( "INSERT INTO awards VALUES (NULL, '%s', '%s')",


return 'You addded: ' . $bestActor . $worstActor . '. The Query string is: ' . $insert;



Here is the configConn.inc.php:

And finally here is the bootstrapper.php file:
[cc lang="php"]

error_reporting(E_ALL | E_STRICT);
ini_set("display_errors", "on");

ini_set("include_path", ini_get("include_path") . ":'/*my path to Zend*/");

require_once Zend/Amf/Server.php';
require_once 'awards.php';

$server = new Zend_Amf_Server();

// You can keep adding all the classes you need here




P.S. I apologize in advance for any typos due to attempting to make the code more generic.

Leave a Reply

Your email address will not be published. Required fields are marked *