[FLASH8] PHP/mySQL/LoadVars Problem

Ok, I’m starting to go crazy here. I’m trying to do a simple LoadVars operation to get Flash to hit a PHP script which queries a database and returns the results to Flash. I’ve done this before and never had these kind of problems…so either I’m completely losing my mind or I’m doing something horribly wrong.

Here’s what I have:

Flash 8 Pro, PHP 5 and mySQL 5 which are running on an Apache 2 server, and I have Flash Player 8.5 installed.

Here’s my code:

PHP

<?php
    include "db_details.php";
    
    $whichSet = $_POST["whichSet"];
    //$whichSet = "all";
    
    if($whichSet == "all"){
        $queryString = "SELECT * FROM cardsets";
    } else {
        $queryString = "SELECT * FROM cardsets WHERE cardsets.setType = '$whichSet'";
    }
    
    $mysql_connection = @mysql_connect($hostname, $username, $password);
    mysql_select_db($database);
    
    $qr = $queryString;
    
    $Result = mysql_query($qr);
    $nRows = mysql_num_rows($Result);
    
    $Return = "&success=yes&n=".$nRows;
    
    for($i=0; $i<$nRows; $i++){
        $row = mysql_fetch_array($Result);
        $Return .= "&set".$i."=".$row['setName'];
    }
    
    mysql_free_result($Result);
    echo $Return;
?>

**ActionScript

**

setQuery = new LoadVars();
setQuery.onLoad = setsLoaded;
setQuery.whichSet = setType;
setQuery.sendAndLoad("php/getSets.php", setQuery, "POST");

function setsLoaded(){
        trace("Success = " + this["success"]);
        trace("Number of sets = " + this["n"]);
}

The problem is when the data comes back to Flash. It appears that there is TOO MUCH data being returned. Here is what the above trace statements send to my output window.

Success = yes
Number of sets = ".$nRows;

    

    for($i=0; $i<$nRows; $i  ){

        $row = mysql_fetch_array($Result);

        $Return .= "

So as you can see, instead of returning the number of results as I want it to, it’s sticking in the PHP code in between the set of quotes.

Am I a complete idiot? Am I totally missing something? I’ve been staring and tweaking this code for hours. I’ve gone through every tutorial I can find and have cut and pasted their code in and same thing. It’s driving me CRAZY?!

Could this be some sort of bug with Flash Player 8.5 or Flash 8 Pro?

I’m so lost. Any help or suggestions y’all could give would be greatly appreciated.

Thanks,
RD