Issues with As3 and PHP

Hello All :slight_smile:

What I am trying to do is set up a basic php mySQL AS3 collaboration. I have a flash file that has a text field where you register a username and an email, then a php file that this data is sent to and a SQL database where it is stored with a primary key that auto_incriments and returns the ID to the php file as a variable usrID.

php:




$database = "testDB";

$con = mysql_connect('localhost', 'root', 'root');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db($database, $con);

$sql="INSERT INTO usrData (usrName, usrEmail) VALUES ('$_POST[theName]','$_POST[theEmail]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
  
      $usrID = mysql_insert_id();
      $r_string = '&errorcode=0&id='.$id.'&';

  
echo "1 record added";
echo $usrId;

mysql_close($con)



?>

AS3

public function sendToSQL(qID:String){
            
            //_testDisplay.text = str;
            _testDisplay.y = 190;
            _testDisplay.x = 30;
            _testDisplay.width = 600;
            this.addChild(_testDisplay);
            
            scriptVars.theName = usrName;
            scriptVars.theEmail = usrEmail;
            scriptVars.questID = qID;
            scriptVars.theComment = _usrInput.text;
            
            scriptRequest.method = URLRequestMethod.POST;
            scriptRequest.data = scriptVars;

            scriptLoader.load(scriptRequest);
            
            //trace(scriptLoader.data["usrID"]);
            
        }
       
        
        
        private function handleLoadSuccessful(evt:Event){
            trace("Message sent.");
            
             trace(evt.target.data["usrID"]);
            
            
        }

 
        private function handleLoadError(evt:IOErrorEvent){
            trace("Message failed.");
        }        

LoadSuccessfull is called by an event listener called up above not listed here. But it does run as “Message sent” is traced.

All i’m trying to do is get the usrID BACK to flash. And I keep getting this error:

ReferenceError: Error #1069: Property usrID not found on String and there is no default value.
I have a feeling i am just putting this in the wrong place, as the php file hasn’t recieved the usrID when I ask for it. But I can’t figure out how to solve this problem. Any help?

Thanks to anyone with the time :slight_smile:
-Brandon