Flash PHP mysql communication problem


Im trying to make a simple flash site which gets its main content from a database. I try to use the database class to connect mx and Mysql (found in exellent beginner/advanced book php5 for flash)

Anyway, this is the database.php

class Database {
  var $dbHost;
  var $dbUser;
  var $dbPass;
  var $dbName;
  var $flash;
  var $dbLink;
  var $result;
  var $resultObj;
  function Database($dbHost, $dbUser, $dbPass, $dbName, $flash=1){
	$this->host = $dbHost;
	$this->user = $dbUser;
	$this->pwd = $dbPass;
	$this->dbName = $dbName;
 $this->flash = $flash;
  // Connect to the mySQL Server and Select the database
  function connect() {
	$this->dbLink = @mysql_pconnect($this->host, $this->user, $this->pwd);
	if (!$this->dbLink) {
	   $error = 'Couldn\'t connect to mySQL Server';
	echo $this->flash ? 'error='.urlencode($error) : $error;
	if ([email protected]_select_db($this->dbName, $this->dbLink)) { 
	  $error = 'Couldn\'t open Database: '. $this->dbName;
   echo $this->flash ? 'error='.urlencode($error) : $error;
 return $this->dbLink;  
  // Execute an SQL query
  function query($query) {
	$this->result = @mysql_query($query, $this->dbLink);
 if (!$this->result) {
   $error = 'MySQL Error: ' . mysql_error();
   echo $this->flash ? 'error='.urlencode($error) : $error;
 // store result in new object to emulate mysqli OO interface
 $this->resultObj = new MyResult($this->result);
 return $this->resultObj;
  function close(){
	// Close MySQL Connection
class MyResult {
  var $theResult;
  var $num_rows;
  function MyResult(&$r) {
	if (is_bool($r)) {
   $this->num_rows = 0;
 else {
   $this->theResult = $r;
	  // get number of records found
   $this->num_rows = @mysql_num_rows($r);
  // fetch associative array of result (works on one row at a time) 
  function fetch_assoc() {
	$newRow = @mysql_fetch_assoc($this->theResult);
 return $newRow;

and here is my returnData.php script


$db = new Database('localhost', 'username', 'password', 'database');
$sql="SELECT * FROM siteData WHERE section_id='$theRow'";
$result= $db->query($sql);
[email protected]_fetch_array($result);
echo "&theText=$theText&theImage=$theImage";

The idea is that a table is searched by section_id and this returns text and a link to a .jpg file that should load up. (both of them dont!)
Somehow the script ‘works’ but the sql query returns 0 and so I dont see data appearing in the swf.

Any suggestions are welcome, thanks ken