# How do I pull a variable from php (or XML) into dynamic textbox?

**URL:** <https://forum.kirupa.com/t/how-do-i-pull-a-variable-from-php-or-xml-into-dynamic-textbox/287846>\
**Category:** flash\
**Created:** [May 6, 2009, 11:21pm UTC](https://forum.kirupa.com/t/how-do-i-pull-a-variable-from-php-or-xml-into-dynamic-textbox/287846 "2009-05-06T23:21:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brellis](https://avatars.discourse-cdn.com/v4/letter/b/b38774/32.png) [@brellis](https://forum.kirupa.com/u/brellis)\
**Post date:** [May 6, 2009, 11:21pm UTC](https://forum.kirupa.com/t/how-do-i-pull-a-variable-from-php-or-xml-into-dynamic-textbox/287846/1 "2009-05-06T23:21:28Z")

</div>

OK, I have my php and MySQL working fine. I’m pulling the data. I found how to format the data that is returned in the php as XML. My problem is I can’t get my Flash textbox to load the variable from the php file. Like most things, this is probably very easy if you know how. I feel quite stupid…help!

My flash dynamic textbox is given the variable name topTeacher. From what I understand, I don’t need to worry about an instance name.

My php file looks like this:  
[INDENT]_[COLOR=darkred]\<?php[/COLOR]_  
_[COLOR=darkred]$con = mysql\_connect(“localhost”, “USERNAME”, “PASSWORD”) or die(‘Could not connect to server’);[/COLOR]_  
_[COLOR=darkred]mysql\_select\_db(“technology”, $con) or die(‘Sorry, could not connect to the database’);[/COLOR]_  
_[COLOR=darkred]$sql = “SELECT \* FROM teacher INNER JOIN rating ON teacher.teacher\_id=rating.rating\_id ORDER BY rating DESC LIMIT 1”;[/COLOR]_  
_[COLOR=darkred]$result = mysql\_query($sql) or die(‘Sorry, could not get name and ratings’);[/COLOR]_  
_[COLOR=darkred]echo "\<?xml version=“1.0”?\>  
";[/COLOR]_  
_[COLOR=darkred]echo "\<topTeacher\>  
";[/COLOR]_  
_[COLOR=darkred]while ($line=mysql\_fetch\_assoc($result)){[/COLOR]_  
_[COLOR=darkred]echo $line[“firstname”]." “.$line[“lastname”].” ".$line[“rating”];[/COLOR]_  
_[COLOR=darkred]}[/COLOR]_  
_[COLOR=darkred]echo "\</topTeacher\>  
";[/COLOR]_  
_[COLOR=darkred]mysql\_close($con);[/COLOR]_  
_[COLOR=darkred]?\>[/COLOR]_  
[/INDENT]The output currently looks like this on the screen: [COLOR=darkred]_Sam Pull 18_[/COLOR].  
The source code created by the php script looks like this:  
[INDENT][COLOR=darkred]_\<?xml version=“1.0”?\>_[/COLOR]  
[COLOR=darkred]_\<topTeacher\>Sam Pull 18\</topTeacher\>_[/COLOR]  
[/INDENT]What should my actionscript be in the frame to pull the data in? Any help would be GREATLY appreciated.
