# Loading php into flash question

**URL:** <https://forum.kirupa.com/t/loading-php-into-flash-question/7754>\
**Category:** Uncategorized\
**Created:** [November 7, 2002, 1:10am UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754 "2002-11-07T01:10:39Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![parabol](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@parabol](https://forum.kirupa.com/u/parabol)\
**Post date:** [November 7, 2002, 1:10am UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/1 "2002-11-07T01:10:39Z")

</div>

ok, basically i have properly gotten php to load into my dynamic txt boxes…callign htem from a php app…etc etc… but heres my question… can php be loaded into a swf that on the main timeline has a movie clip inbedded in it.inside this movie is the dynamic txt boxes etc.  
now i also made one with the movies layers on my main timeline.  
This worked…  
now do i need to use the \_root command r anything like that to specify a instance or movie clip to properly display the php…cause right now it only appears in the version on the main timeline.

on the submit button this is the code…  
on (release) {  
loadVariablesNum(“scriptA.php”, 0, “POST”);  
loading = “YES”;  
gotoAndPlay(21);  
}  
then on layer 23 this is what i have  
if (loading eq “YES”) {  
gotoAndPlay(\_currentframe-1);  
} else {  
gotoAndStop(20);  
}  
this is frame 20 not monster eye smiley;)  
all i want is to make the php appear in the swf with the movie clip…everything is all lines up and now i have to re align everyhting liek 20 swfs perfectly if i choose to do it the other way…

---

<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:** [November 7, 2002, 9:42am UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/2 "2002-11-07T09:42:06Z")

</div>

as i can see in your script, you have loaded the php variables in the \_level 0, so, you just have to make reference like \_level0.variableName, to use it in your mc, or just a \_root.variableName. Or you could load the variables within the MC. Any of these shall work. If you find any problem just aks, i work with flash and 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:** [November 7, 2002, 7:58pm UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/3 "2002-11-07T19:58:00Z")

</div>

where would i actually put t hat in… is my script ok or should the \_root be in there somewhere… coudl u give me a example of something similar or explain more.

thanx

---

<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:** [November 8, 2002, 10:40am UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/4 "2002-11-08T10:40:39Z")

</div>

let me give you an example:

**Actionscript**  
on(release){  
pega\_texto = new LoadVars();  
pega\_texto.load(“search\_kirupa.php”, “”, “post”);  
pega\_texto.onLoad = function(){  
mc\_text.load\_text.text = this.v1;  
}  
}

mc\_text is a MovieClip in the \_root, load\_text is a dynamic text field within mc\_text.

**PHP**  
\<?php  
$host = “localhost”;  
$user = “richie”;  
$pass = “eihcir”;  
$db = “mydb”;

$conexao = mysql\_connect($host, $user, $pass);  
$banco = mysql\_select\_db($db, $conexao);  
$sql = “select \* from kirupa1”;  
$busca = mysql\_query($sql, $conexao);

$campo = mysql\_fetch\_array($busca);  
$valor1 = $campo[‘content’];

echo “v1=$valor1”;  
?\>

kirupa1 wuld be the table, and content it’s one row.

any doubts, just ask.

---

<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:** [November 8, 2002, 10:38pm UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/5 "2002-11-08T22:38:43Z")

</div>

its hard for me to understand that in spanish. kind but. how could i apply the mc\_text.load\_text.text = this.v1;  
type stuff in my actionscript. so stats1 is my movie clip andscore1 one is a input text feild in the clip.  
so i got  
stats1.score1… now i dont know how to apply that ot my script  
on the submit button this is the code…  
on (release) {  
loadVariablesNum(“scriptA.php”, 0, “POST”);  
loading = “YES”;  
gotoAndPlay(21);  
}  
then on layer 23 this is what i have  
if (loading eq “YES”) {  
gotoAndPlay(\_currentframe-1);  
} else {  
gotoAndStop(2;  
}

where would i apply that in here…can u try…?? thanks for the 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:** [November 9, 2002, 10:32pm UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/6 "2002-11-09T22:32:48Z")

</div>

yes , to apply the texto in you mc’s text field, you have to do this as you said:  
stats1.score1.text = this.v1;  
stats1.score1.text is the path to the text field, and this(the object) has the variable v1 wich contains the data from mysql.

another thing, anyone correct me if i am wrong, but one of the worst things to pass just some variables to a mc is use loadVariablesNum, i sugest you to understand how is the exacly function of the loadvars object.

you said you speak spanish did you?  
if you’d like to see some portuguese tutorials, you can see a good one at [http://www.imasters.com.br](http://www.imasters.com.br) there’s a lot of stuff there.

if you need more help i’m 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:** [November 10, 2002, 5:56pm UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/7 "2002-11-10T17:56:19Z")

</div>

I have the same problem. I’ve tried the loadVars function to load text into my dynamic textfield inside an MC. the text load fine, but the problem is I have HTML tags in the textfile and with LoadVars all those tags print out. It seems like loadVariablesNum is the only one to correctly pass those HTML variables to the textfield…

loadVariablesNum(“guestbook.txt”, 0 ) works fine as long as the textfield is at root, but as soon as I put the dynamic textbox into an MC the text won’t load anymore. I’ve tried putting \_root/[mc]/guestbook= in the guestbook.txt file but to no reward.

please 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:** [November 10, 2002, 6:05pm UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/8 "2002-11-10T18:05:29Z")

</div>

i think u should use unescape when loading Html Tags!

```php
Var = unescape(LoadVarsObjectName.externalVars);

```

that should work!

yours,  
–h88

---

<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:** [November 10, 2002, 6:47pm UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/9 "2002-11-10T18:47:08Z")

</div>

hi, the php script is fine. it’s when I load it into flash that things become weird. though, when I use LoadVariablesNum it loads fine.

I’ve managed to use loadVariablesNum(“guestbook.txt”, 0) in root and use \_root.[MC].guestbook= in the guestbook.txt file. It works great…until I load the whole guestbook.swf into another movie at level 2 and then another movie that loads the second one into level 20… do I need to use 20+2 for level or…?

---

<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:** [November 11, 2002, 9:29am UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/10 "2002-11-11T09:29:54Z")

</div>

you said your html tags print out in you dynamic text with the script i pass you. that’s correct, that isn’t the correct sintax to use with html tags, in this case the same line would be written this way:

mc\_text.load\_text.htmlText = this.v1;

as you can see, you don’t use the property “text” anymore, you use “htmlText”. Try this and see if it works out!

---

<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:** [November 11, 2002, 5:13pm UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/11 "2002-11-11T17:13:51Z")

</div>

Thanks for your answer Richie. I got it right the other way, but I’ll keep this in mind next time I want to import text 😉

---

<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:** [November 11, 2002, 11:26pm UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/12 "2002-11-11T23:26:21Z")

</div>

ok i get what ur saying but look at my code i posted in the past few posts. where exaclty do i place the new code. do i place it in a action on the main timeline that contians the mc or do i open the movie clip and apply it in there. this is where im confused… the actual placement of the varable…???..if anyone is williong to look at the code please email me at [parabol@parabol-designs.com](mailto:parabol@parabol-designs.com)  
help will be so appreciated…as this is keeping our project behind…

---

<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:** [November 12, 2002, 12:15am UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/13 "2002-11-12T00:15:27Z")

</div>

whats 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:** [November 12, 2002, 8:24am UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/14 "2002-11-12T08:24:08Z")

</div>

cute:o

---

<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:** [November 12, 2002, 8:36am UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/15 "2002-11-12T08:36:47Z")

</div>

maybe he really doesn’t know. 🙂 don’t assume anything. Some of us are very serverside illiterate. Like me for instance. (so if I got the below incorrect, just correct me please 🙂 )

PHP is a form of CGI. CGI is a scripting language which can do many things but is most commonly used (I think) for routing data between databases and the viewer of a web page. It is very good at understanding one type of language and then parsing that data into other forms. ie you can use PHP to take data from a database and send it to Flash, AND vis-versa.

---

<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:** [November 12, 2002, 12:09pm UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/16 "2002-11-12T12:09:43Z")

</div>

Parabol, you have to put that script in the main timeline, and erase that aold you posted.

---

<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:** [November 12, 2002, 3:55pm UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/17 "2002-11-12T15:55:10Z")

</div>

cool i will work with that today…

---

<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:** [November 12, 2002, 10:06pm UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/18 "2002-11-12T22:06:00Z")

</div>

onClipEvent (load) {  
stats = new LoadVars();  
stats.load(“ScriptAtest.php”, “this”, “post”);  
stats.onLoad = function(){  
stats1.total1.text = this.v1;  
}  
}

i have this in the main time line… yet my data isnt displaying

reason being in the movie clip there is a input text field and a dynamic text field. so when u type in a # int he input it will display in the dynamic. after its been formatted by php. and after u click on a submit button. this code worked on the main timeline to get a number to appear on the dynamic field from php which is named total1  
onClipEvent (load) {  
loadVariables(“ScriptAtest.php”, this, “POST”);  
}

but the php was simple total1 = 6 basically…it didnt take the input cause we cant get the input to reappear when it come from php…php is getting the input cause its stored in the database. we can make it appear staticly but thats not gonna work…  
if u wanna see it or need to get in touch with me i can give u link or email me [parabol@parabol-designs.com](mailto:parabol@parabol-designs.com)

thanks

---

<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:** [November 13, 2002, 9:37am UTC](https://forum.kirupa.com/t/loading-php-into-flash-question/7754/19 "2002-11-13T09:37:43Z")

</div>

no, you are doing wrong, not in onClipEvent(load) that script i did to be in a frame. If you will attach to a mc, it’s has to be changed a little. Try to put that script into a frame, if this didn’t work then tell me then i’ll do a example for you everything working and then i send it to you. What about that?
