# Actionscript Code not working - connecting to MySQL

**URL:** <https://forum.kirupa.com/t/actionscript-code-not-working-connecting-to-mysql/65202>\
**Category:** flash\
**Created:** [September 23, 2004, 11:11pm UTC](https://forum.kirupa.com/t/actionscript-code-not-working-connecting-to-mysql/65202 "2004-09-23T23:11:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaykills](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kaykills/32/228_2.png) [@kaykills](https://forum.kirupa.com/u/kaykills)\
**Post date:** [September 23, 2004, 11:11pm UTC](https://forum.kirupa.com/t/actionscript-code-not-working-connecting-to-mysql/65202/1 "2004-09-23T23:11:56Z")

</div>

Hi,  
I did a tutorial on how to connect a Flash Dynamic text box to a MySQL database. I created a PHP file which connects to the database and displays fine. The tricky part has been getting Flash to display the results in the PHP file. Here is my AS code. If anyone can see what I am doing wrong can you help please. Much appreciated.

```auto

//function to load external data using the loadVars() object
//l=name of loadVars object
//n=name of text field 
//t=trigger to decide whether to show all entries or just one.
//e= entry number to display (number)
//f=file to load from (string)
function lv(l, n, t, e, f) {
	sb.setSize(null, 200);
	sb2.setSize(null, 50);
	//create a new loadVars object if one doesn't already exist if it does, use it
	if (l == undefined) {
		l = new LoadVars();
		l.onLoad = function() {
			var i;
			//clear out any text that might already be there
			n.htmlText = "";
			//to show a single entry at a time we use the following code
			if (t == undefined) {
				n.htmlText += "<b>"+this["date"+e]+" - "+this["location"+e]+"</b><br><br>";
				n.htmlText += this["comment"+e];
			} else {
				//cycle through and show all entries
				for (i=0; i<this.n; i++) {
					n.txt.htmlText += "<u><a href='asfunction:_root.loadArc,"+this["id"+i]+"'>"+this["date"+i]+" - "+this["location"+i]+"</a></u><br>";
				}
			}
			sb.update();
			sb2.update();
		};
	}
	l.load(f);
	
	function loadArc(passed) {
	arcNum = passed-1;
	lv(entries_lv, entries_txt, undefined, arcNum, "../php/shows-query.php");
	//for the large entry textfield 
lv(entries_lv, entries_txt, undefined, 0, "../php/shows-query.php"); 
//for the archives text field 
lv(archive_lv, archive_txt, "cycle", null, "../php/shows-query.php");

	}
	
}

```

Thank you  
Kay

---

<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:** [September 23, 2004, 11:13pm UTC](https://forum.kirupa.com/t/actionscript-code-not-working-connecting-to-mysql/65202/2 "2004-09-23T23:13:20Z")

</div>

a

---

<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:** [September 24, 2004, 8:13am UTC](https://forum.kirupa.com/t/actionscript-code-not-working-connecting-to-mysql/65202/3 "2004-09-24T08:13:38Z")

</div>

looks very complicated, can you give the url of the output generated by 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:** [September 24, 2004, 1:11pm UTC](https://forum.kirupa.com/t/actionscript-code-not-working-connecting-to-mysql/65202/4 "2004-09-24T13:11:55Z")

</div>

> [@pietertje](#):
>
> looks very complicated, can you give the url of the output generated by php?

for sure… sorry I should have done that.

[http://www.yokocasionos.com/php/shows-query.php](http://www.yokocasionos.com/php/shows-query.php)

If you need the actual php code I can post it when I get home. the output page of the flash file is here as well:

[flash output page](http://www.yokocasionos.com/flash/shows-db-test.swf)

You can see from this page that no information is being picked up at all, even resizing the scrollbar etc.

Cheers  
Michael

---

<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:** [September 24, 2004, 1:43pm UTC](https://forum.kirupa.com/t/actionscript-code-not-working-connecting-to-mysql/65202/5 "2004-09-24T13:43:34Z")

</div>

i saw some double &-signs thats not “good”…

simple version would be like this (i think), if this works you can change the trace functions for somthing to add the text…

lv = new LoadVars();  
lv.load(“[http://www.yokocasionos.com/php/shows-query.php](http://www.yokocasionos.com/php/shows-query.php)”);  
lv.onLoad = function(succes)  
{  
\*\*\*\*if(succes)  
\*\*\*\*{  
\*\*\*\*\*\*\*\*for(var i = 0; i \< this.n; i++){  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*trace(this[“date” + i]);  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*trace(this[“location” + i]);  
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*trace(this[“comment” + i]);  
\*\*\*\*}  
\*\*\*\*else  
\*\*\*\*{  
\*\*\*\*\*\*\* trace(“Loading Error!!”);  
\*\*\* }  
}
