# \[php\] send simple data from php to flash

**URL:** <https://forum.kirupa.com/t/php-send-simple-data-from-php-to-flash/58067>\
**Category:** programming\
**Created:** [July 19, 2004, 3:39pm UTC](https://forum.kirupa.com/t/php-send-simple-data-from-php-to-flash/58067 "2004-07-19T15:39:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alapimba](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@alapimba](https://forum.kirupa.com/u/alapimba)\
**Post date:** [July 19, 2004, 3:39pm UTC](https://forum.kirupa.com/t/php-send-simple-data-from-php-to-flash/58067/1 "2004-07-19T15:39:25Z")

</div>

hello  
this is probably the simplest question about working with php and flash but i’m sick of search and i can’t find the answer or a tutorial that do exactly what i want ☹

i have this php script to get data from my mysql database and i want this data to appear on a flash textfield. i want ALL the data. not only the data from the first row.

the script i’m using is:

\<?php  
mysql\_connect(“localhost”,“ **","** ”);  
mysql\_select\_db(“flash\_news”);  
$qr = mysql\_query(“SELECT \* FROM flash\_news”);  
$nrows = mysql\_num\_rows($qr);  
for ($i=0; $i \< $nrows; $i++) {  
$row = mysql\_fetch\_array($qr);  
echo $row[‘author’].", “.$row[‘title’].”\<br\>";  
echo " “.$row[‘body’].” “.$row[‘timestamp’].”\<br\>\<br\>";  
}  
?\>

now anyone can please(!!) tell me how to put this in a flash txt field?  
Thanks alot and sorry for ask something to basic but i can’t find any tutorial with this. all tutorials that i find is for more complex things and i just need this for now :]

Thanks for your help.

I’ll probably only need to add code to the text field but if’s it’s more than this please explain step by step :sigh:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2004, 4:24pm UTC](https://forum.kirupa.com/t/php-send-simple-data-from-php-to-flash/58067/2 "2004-07-19T16:24:45Z")

</div>

```php

  <?php
  mysql_connect("localhost"," ****","****");
  mysql_select_db("flash_news");
  $qr = mysql_query("SELECT * FROM flash_news");
  while($row = mysql_fetch_assoc($qr)) {
   echo $row['author'].", ".$row['title']."<br>";
  echo " ".$row['body']." ".$row['timestamp']."<br><br>";
  }
  

```

While   
[Assoc](http://www.php.net/manual/en/function.mysql-fetch-assoc.php)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2004, 4:49pm UTC](https://forum.kirupa.com/t/php-send-simple-data-from-php-to-flash/58067/3 "2004-07-19T16:49:45Z")

</div>

this is your help? ☹

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2004, 5:41pm UTC](https://forum.kirupa.com/t/php-send-simple-data-from-php-to-flash/58067/4 "2004-07-19T17:41:00Z")

</div>

er… but and what i have to do in flash for this script work?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2004, 6:03pm UTC](https://forum.kirupa.com/t/php-send-simple-data-from-php-to-flash/58067/5 "2004-07-19T18:03:13Z")

</div>

I dunno if this helps or works, its bits of something I am working on and I dont know crap about PHP/mySQL.

```php

   $DBhost = " *****";   
   $DBuser = " *****";			
   $DBpass = " *****";		   
   $DBName = " *****";			
   $table = " *****";			 
	 
   $DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error" . mysql_error());
	  mysql_select_db($DBName, $DBConn) or die("Error" . mysql_error());

   $action = $_GET['action'];
   
   switch($action) {
	  case 'read' :
	  $sql = 'SELECT * FROM `' . $table . '`';  
	  $allComments = mysql_query($sql, $DBConn) or die("Error" . mysql_error());
	  $numallComments = mysql_num_rows($allComments);

   print "<br>&info="; 
	 if($numallComments == 0) {
	  print " No data.."; } 
   else { while ($array = mysql_fetch_array($fewComments)) {
		 $data = mysql_result($fewComments, $i, 'data');
		 
	print 
	 '
	Data: </b><br>' . $data . '</i><br>
	';
		   $i++;
	  }}
 

```

In flash

```php

function loadEntries(act, increment) {
 
myEntries = new LoadVars() myEntries.ref = this
 myEntries.load("myphpfile.php?action=read&r="+random(999)+"&NumLow="+_parent.NumLow) 
 myEntries.onLoad = function(success){ 
  if(success){ 
   
   
mytextbox.text = this.info;
}

```
