# loadVariables

**URL:** https://forum.kirupa.com/t/loadvariables/24834
**Category:** Uncategorized
**Created:** [July 5, 2003, 6:30pm UTC](https://forum.kirupa.com/t/loadvariables/24834 "2003-07-05T18:30:48Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Voetsjoeba](https://avatars.discourse-cdn.com/v4/letter/v/ac91a4/32.png) [@Voetsjoeba](https://forum.kirupa.com/u/Voetsjoeba)
#### Post date: [July 5, 2003, 6:30pm UTC](https://forum.kirupa.com/t/loadvariables/24834/1 "2003-07-05T18:30:48Z")

</div>

Hi everyone 🙂

I am trying to get data from a MySQL database into Flash. In flash, I have  
[AS]  
loadVariables(“news.php”,“content”);  
[/AS]

on the first frame of the main movie where content is the movieclip the variables should be loaded into. Inside content, I have a dynamic text field with the var ‘inhoud’. On the left of that dynamic textfield, there is an empty movieclip called ‘img’, in which an image should load. So on that movieclip I have

[AS]  
onClipEvent(load){  
\_parent.img.loadMovie(“home”+i+".jpg");  
}  
[/AS]

Now, the php file “news.php” contains the following:

```php
<?
mysql_connect("localhost", "voetsjoeba","--hidden--");
mysql_select_db("voetsjoeba");

$qr = mysql_query("SELECT * FROM news");

$nrows = mysql_num_rows($qr);
for ($i=0; $i < $nrows; $i++){
$row = mysql_fetch_array($qr);

$output="";
$output.= "&i=".$nrows;
$output.= "&img".$i."=".$row['img'];
$output.= "&datum".$i."=".$row['datum'];
$output.= "&inhoud".$i."=".$row['inhoud'];
}

print $output;
?>

```

( Thanks a million to Jubba for helping me out with the PHP :love: )

This doesn’t work. Why not ?

---

<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 5, 2003, 7:51pm UTC](https://forum.kirupa.com/t/loadvariables/24834/2 "2003-07-05T19:51:25Z")

</div>

getURL(url, target, **METHOD** )  
mthod: POST or GET

---

<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 5, 2003, 7:54pm UTC](https://forum.kirupa.com/t/loadvariables/24834/3 "2003-07-05T19:54:47Z")

</div>

he’s trying to load the data into Flash. Not display the PHP page.

---

<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 5, 2003, 8:10pm UTC](https://forum.kirupa.com/t/loadvariables/24834/4 "2003-07-05T20:10:27Z")

</div>

I can see many errors… besides, use LoadVars

```auto

lv = new LoadVars()
lv.onLoad = function(success) {
if (success) {
i = this.i;
trace(i)
img = this.img;
trace(img);
datum = this.datum;
trace(datum);
inhoud = this.inhoud;
trace(inhoud);
_root[img].loadMovie("home"+i+".jpg");
} else {
trace("failed to load script");
}
}
lv.load("news.php")

```

try that, let me know how it goes 🙂

---

<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 5, 2003, 8:39pm UTC](https://forum.kirupa.com/t/loadvariables/24834/5 "2003-07-05T20:39:06Z")

</div>

Ok, I’ll try that 🙂 Thanks ahmed 🙂

---

<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 6, 2003, 10:27am UTC](https://forum.kirupa.com/t/loadvariables/24834/6 "2003-07-06T10:27:05Z")

</div>

A part works ! 😛 I added an extra textfield on top to display the amount of rows. In that textbox, it is supposed to fill in the value of the varibale “i”, which it got out of the PHP script. This is a good sign, because I know now that it did recieve the variables. But the other fields didn’t get filled in … Is it possible that I have to change “datum = this.datum” to “this.datum = datum” ? I’m not sure what the variable is and what the path to the textfield is here … 😛

---

<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 6, 2003, 10:41am UTC](https://forum.kirupa.com/t/loadvariables/24834/7 "2003-07-06T10:41:42Z")

</div>

> \*Originally posted by Voetsjoeba \*  
> \*\*is it possible that I have to change “datum = this.datum” to “this.datum = datum” ? I’m not sure what the variable is and what the path to the textfield is here … 😛 \*\*  
> no… can i see a dummy FLA?

---

<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 6, 2003, 11:27am UTC](https://forum.kirupa.com/t/loadvariables/24834/8 "2003-07-06T11:27:17Z")

</div>

Well, I’ve set up a SWF online to test he variables, you can see it here: [http://voetsjoeba.xszone.nl/test/test.html](http://voetsjoeba.xszone.nl/test/test.html) and the swf fle is [http://voetsjoeba.xszone.nl/test/test.swf](http://voetsjoeba.xszone.nl/test/test.swf) . Maybe the SWF is better to see, cuz the font size is quite small …

It fills in i (3), which is correct, but it doesn’t recognise the other variables, ‘inhoud’ en ‘datum’. I’ll post the dummy FLA in a sec.

---

<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 6, 2003, 11:36am UTC](https://forum.kirupa.com/t/loadvariables/24834/9 "2003-07-06T11:36:53Z")

</div>

```php
$output="";
$output.= "&i=".$nrows;
$output.= "&img".$i."=".$row['img'];
$output.= "&datum".$i."=".$row['datum'];
$output.= "&inhoud".$i."=".$row['inhoud'];
}

```

if you get rid of the $i, it would 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 6, 2003, 11:42am UTC](https://forum.kirupa.com/t/loadvariables/24834/10 "2003-07-06T11:42:30Z")

</div>

Thanks =) Lemme try.

[EDIT] It works !!! Thank you thank you thank you !![/EDIT]
