# \[AS\]\[PHP\]\[MYSQL\]Something big, can you help me?

**URL:** <https://forum.kirupa.com/t/as-php-mysql-something-big-can-you-help-me/184341>\
**Category:** flash\
**Created:** [April 4, 2006, 2:15pm UTC](https://forum.kirupa.com/t/as-php-mysql-something-big-can-you-help-me/184341 "2006-04-04T14:15:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![btibia](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/btibia/32/1625_2.png) [@btibia](https://forum.kirupa.com/u/btibia)\
**Post date:** [April 4, 2006, 2:15pm UTC](https://forum.kirupa.com/t/as-php-mysql-something-big-can-you-help-me/184341/1 "2006-04-04T14:15:57Z")

</div>

Hello,

I have a big problem and i don’t know what is wrong! This problem sounds like this:  
---------------------------------A little description of the site.  
I have a main movie where i have 4 movieClips (with the instance name: home\_mc, club\_mc, gute\_mc and stuff\_mc), initial they are invisible (ex: home\_mc.\_visible = false and when i click a button the movieClip assign to that button will become visible.  
I have in every movieClip some text areas(input and dynamically), datagrids and button and in action layer i have #include "_.as" (_ = the name of the movieClip; home has home.as, club has club.as etc)  
Here are the actionscript files:  
Main.as  
[AS]  
//Site initial property.  
home\_mc.\_visible = false;  
club\_mc.\_visible = false;  
gute\_mc.\_visible = false;  
stuff\_mc.\_visible = false;  
kontakt\_mc.\_visible = false;  
news\_mc.\_visible = false;  
adver\_mc.\_visible = false;  
//Initial Animation Components  
//  
//Tween First View.  
import mx.transitions.Tween;  
import mx.transitions.easing._;  
var tw:Tween = new Tween (main\_headline, “\_xscale”, Elastic.easeOut, 0, 100, 3, true);  
var tw1:Tween = new Tween (main\_headline, “\_yscale”, Elastic.easeOut, 0, 100, 3, true);  
//Button Texts  
btn\_home.button\_text\_mc.button\_text.text = “Home”;  
btn\_club.button\_text\_mc.button\_text.text = “Club”;  
btn\_gute.button\_text\_mc.button\_text.text = “gute Scheiben”;  
btn\_stuff.button\_text\_mc.button\_text.text = “DJ Stuff”;  
btn\_kontakt.button\_text\_mc.button\_text.text = “Kontakt”;  
btn\_news.button\_text\_mc.button\_text.text = “News/Specials”;  
btn\_adver.button\_text\_mc.button\_text.text = “Advertising”;  
//Button Actionscript  
btn\_home.onRelease = function () {  
//Tween Home Mc  
var tween\_home = new Tween (home\_mc, “\_xscale”, Elastic.easeOut, 0, 100, 1, true);  
var tween\_home1 = new Tween (home\_mc, “\_yscale”, Elastic.easeOut, 0, 100, 1, true);  
var tween\_home2 = new Tween (home\_mc, “\_alpha”, Elastic, easeInOut, 0, 100, 1, true);  
//_  
//  
home\_mc.\_visible = true;  
loadMovie(home\_mc);  
//  
club\_mc.\_visible = false;  
club\_mc.unloadMovie();  
gute\_mc.\_visible = false;  
gute\_mc.unloadMovie()  
stuff\_mc.\_visible = false;  
stuff\_mc.unloadMovie()  
kontakt\_mc.\_visible = false;  
kontakt\_mc.unloadMovie()  
news\_mc.\_visible = false;  
news\_mc.unloadMovie()  
adver\_mc.\_visible = false;  
adver\_mc.unloadMovie()  
};  
btn\_club.onRelease = function () {  
//Tween Club Mc  
var tween\_club = new Tween (club\_mc, “\_xscale”, Elastic.easeOut, 0, 100, 1, true);  
var tween\_club1 = new Tween (club\_mc, “\_yscale”, Elastic.easeOut, 0, 100, 1, true);  
var tween\_club2 = new Tween (club\_mc, “\_alpha”, Elastic, easeInOut, 0, 100, 1, true);  
//\*  
home\_mc.\_visible = false;  
home\_mc.unloadMovie();  
//  
club\_mc.\_visible = true;  
loadMovie(club\_mc);  
//  
home\_mc.\_visible = false;  
home\_mc.unloadMovie();  
stuff\_mc.\_visible = false;  
stuff\_mc.unloadMovie()  
kontakt\_mc.\_visible = false;  
kontakt\_mc.unloadMovie()  
news\_mc.\_visible = false;  
news\_mc.unloadMovie()  
adver\_mc.\_visible = false;  
adver\_mc.unloadMovie()  
};  
btn\_stuff.onRelease = function () {  
//Tween Stuff Mc  
var tween\_stuff = new Tween (stuff\_mc, “\_xscale”, Elastic.easeOut, 0, 100, 1, true);  
var tween\_stuff = new Tween (stuff\_mc, “\_yscale”, Elastic.easeOut, 0, 100, 1, true);  
var tween\_stuff = new Tween (stuff\_mc, “\_alpha”, Elastic, easeInOut, 0, 100, 1, true);  
//\*  
home\_mc.\_visible = false;  
home\_mc.unloadMovie();  
club\_mc.\_visible = false;  
club\_mc.unloadMovie()  
home\_mc.\_visible = false;  
home\_mc.unloadMovie();  
//  
stuff\_mc.\_visible = true;  
//  
kontakt\_mc.\_visible = false;  
kontakt\_mc.unloadMovie()  
news\_mc.\_visible = false;  
news\_mc.unloadMovie()  
adver\_mc.\_visible = false;  
adver\_mc.unloadMovie()  
};  
btn\_gute.onRelease = function () {  
//Tween Stuff Mc  
var tween\_gute = new Tween (gute\_mc, “\_xscale”, Elastic.easeOut, 0, 100, 1, true);  
var tween\_gute = new Tween (gute\_mc, “\_yscale”, Elastic.easeOut, 0, 100, 1, true);  
var tween\_gute = new Tween (gute\_mc, “\_alpha”, Elastic, easeInOut, 0, 100, 1, true);  
//\*  
home\_mc.\_visible = false;  
home\_mc.unloadMovie();  
club\_mc.\_visible = false;  
club\_mc.unloadMovie()  
//  
gute\_mc.\_visible = true;  
//  
stuff\_mc.\_visible = false;  
stuff\_mc.unloadMovie()  
kontakt\_mc.\_visible = false;  
kontakt\_mc.unloadMovie()  
news\_mc.\_visible = false;  
news\_mc.unloadMovie()  
adver\_mc.\_visible = false;  
adver\_mc.unloadMovie()  
};  
[/AS]

* * *

Home.as  
[AS]  
stop ();  
//  
save\_home.button\_text\_mc.button\_text.text = “Submit to Home”;  
see\_home.button\_text\_mc.button\_text.text = “See Home site”;  
//  
see\_home.onPress = function () {  
loadText = new LoadVars ();  
loadText.load (“home.txt”);  
loadText.onLoad = function () {  
current\_home.text = this.home;  
};  
};  
//  
save\_home.onRelease = function () {  
getURL (“home.php”, \_blank, “POST”);  
};  
[/AS]

* * *

Club.as  
[AS]  
//Show Database in the Data Grid.  
club\_parseXML = function () {  
if (myXML.hasChildNodes) {  
// we check if this xml has children just to be sure  
var xmlRootNode = myXML.firstChild.childNodes;  
// define the root of the xml file for easy navigation  
for (var i = 0; i\<xmlRootNode.length; i++) {  
// now loop through the xml and fill our dataArray with objects  
var thisNode = xmlRootNode\*;  
if (thisNode != null) {  
var strid = thisNode.childNodes[0].firstChild.nodeValue;  
var strpic = thisNode.childNodes[1].firstChild.nodeValue;  
var strtext = thisNode.childNodes[2].firstChild.nodeValue;  
var strlink = thisNode.childNodes[3].firstChild.nodeValue;  
// here we go, creating an object instantly and adding it to our container  
arrDataGrid.push({ID:strid, Pic:strpic, Text:strtext, Link:strlink});  
}  
}  
}  
// this is where the magic is, link the filled array to the datagrid… that’s it!  
// you’ll have full control over what comes in to you grid! Great ain’t it 😉  
club\_dg.dataProvider = arrDataGrid;  
};  
club\_loadXML = function () {  
arrDataGrid = new Array();  
// will contain the data for the grid  
myXML = new XML();  
// loads the xml in memory  
myXML.ignoreWhite = true;  
// ignore enters and whitespace in xml file  
myXML.onLoad = club\_parseXML;  
// reference to the function above  
myXML.load(“club\_db.xml”);  
// the actual command which will load the xml file  
};  
//Finish Load Database in Data Grid.  
//\*  
//Initial propertys.  
club\_dg.\_visible = false;  
refresh\_club.\_visible = false  
//\*  
//Ckeck Box’es.  
// create event listener object for checkbox  
clubbox = new Object();  
// click event handler  
clubbox.click = function() {  
if (club\_db.selected) {  
club\_dg.\_visible = true;  
refresh\_club.\_visible = true;  
club\_loadXML();  
} else {  
club\_dg.\_visible = false;  
refresh\_club.\_visible = false;  
}  
};  
// register the event listener  
club\_db.addEventListener(“click”, clubbox);  
refresh\_club.onPress = function () {  
club\_loadXML();  
}  
//Finish Show Database AS.  
//\*

//Remove ID MC  
remove\_id\_head.\_visible = false;  
remove\_id\_head2.\_visible = false;  
remove\_id\_input.\_visible = false;  
remove\_club.\_visible = false;  
//  
// Check Box  
remove\_club\_ac = new Object();  
// click event handler  
remove\_club\_ac.click = function() {  
if (remove\_club\_mc.selected) {  
remove\_id\_head.\_visible = true;  
remove\_id\_head2.\_visible = true;  
remove\_id\_input.\_visible = true;  
remove\_club.\_visible = true;  
} else {  
remove\_id\_head.\_visible = false;  
remove\_id\_head2.\_visible = false;  
remove\_id\_input.\_visible = false;  
remove\_club.\_visible = false;  
}  
};  
// register the event listener  
remove\_club\_mc.addEventListener(“click”, remove\_club\_ac);  
///\*  
//Alert  
import mx.controls.Alert;  
// Define action after alert confirmation.  
var alertHandler:Function = function (evt\_obj:Object) {  
if (evt\_obj.detail == Alert.YES)  
{  
getURL (“delete\_club.php”, \_blank, “POST”);  
}  
};  
// Show alert dialog box.  
remove\_club.onPress = function () {  
var club\_alert:Alert = Alert.show ("Do you want to remove ID: " + remove\_id\_input.text + “?”, “Validation Alert!”, Alert.YES | Alert.NO, this, alertHandler, Alert.YES);  
club\_alert.\_x = 384.4;  
club\_alert.\_y = 334.5;  
};

[/AS]

* * *

Gute.as  
[AS]  
//Show Database in the Data Grid.  
gute\_parseXML = function () {  
if (myXML.hasChildNodes) {  
// we check if this xml has children just to be sure  
var xmlRootNode = myXML.firstChild.childNodes;  
// define the root of the xml file for easy navigation  
for (var i = 0; i\<xmlRootNode.length; i++) {  
// now loop through the xml and fill our dataArray with objects  
var thisNode = xmlRootNode\*;  
if (thisNode != null) {  
var strid = thisNode.childNodes[0].firstChild.nodeValue;  
var strpic = thisNode.childNodes[1].firstChild.nodeValue;  
var strtext = thisNode.childNodes[2].firstChild.nodeValue;  
var strlink = thisNode.childNodes[3].firstChild.nodeValue;  
// here we go, creating an object instantly and adding it to our container  
arrDataGrid.push({ID:strid, Pic:strpic, Text:strtext, Link:strlink});  
}  
}  
}  
// this is where the magic is, link the filled array to the datagrid… that’s it!  
// you’ll have full control over what comes in to you grid! Great ain’t it 😉  
gute\_dg.dataProvider = arrDataGrid;  
};  
gute\_loadXML = function () {  
arrDataGrid = new Array();  
// will contain the data for the grid  
myXML = new XML();  
// loads the xml in memory  
myXML.ignoreWhite = true;  
// ignore enters and whitespace in xml file  
myXML.onLoad = gute\_parseXML;  
// reference to the function above  
myXML.load(“gute\_db.xml”);  
// the actual command which will load the xml file  
};  
//Finish Load Database in Data Grid.  
//\*  
//Initial propertys.  
gute\_dg.\_visible = false;  
refresh\_gute.\_visible = false  
//\*  
//Ckeck Box’es.  
// create event listener object for checkbox  
gutebox = new Object();  
// click event handler  
gutebox.click = function() {  
if (gute\_db.selected) {  
gute\_dg.\_visible = true;  
refresh\_gute.\_visible = true;  
gute\_loadXML();  
} else {  
gute\_dg.\_visible = false;  
refresh\_gute.\_visible = false;  
}  
};  
// register the event listener  
gute\_db.addEventListener(“click”, gutebox);  
refresh\_gute.onPress = function () {  
gute\_loadXML();  
}  
//Finish Show Database AS.  
//\*

//Remove ID MC  
remove\_id\_head.\_visible = false;  
remove\_id\_head2.\_visible = false;  
remove\_id\_input.\_visible = false;  
remove\_gute.\_visible = false;  
//  
// Check Box  
remove\_gute\_ac = new Object();  
// click event handler  
remove\_gute\_ac.click = function() {  
if (remove\_gute\_mc.selected) {  
remove\_id\_head.\_visible = true;  
remove\_id\_head2.\_visible = true;  
remove\_id\_input.\_visible = true;  
remove\_gute.\_visible = true;  
} else {  
remove\_id\_head.\_visible = false;  
remove\_id\_head2.\_visible = false;  
remove\_id\_input.\_visible = false;  
remove\_gute.\_visible = false;  
}  
};  
// register the event listener  
remove\_gute\_mc.addEventListener(“click”, remove\_gute\_ac);  
///\*  
//Alert  
import mx.controls.Alert;  
// Define action after alert confirmation.  
var alertHandler:Function = function (evt\_obj:Object) {  
if (evt\_obj.detail == Alert.YES)  
{  
getURL (“delete\_gute.php”, \_blank, “POST”);  
}  
};  
// Show alert dialog box.  
remove\_gute.onPress = function () {  
var gute\_alert:Alert = Alert.show ("Do you want to remove ID: " + remove\_id\_input.text + “?”, “Validation Alert!”, Alert.YES | Alert.NO, this, alertHandler, Alert.YES);  
gute\_alert.\_x = 384.4;  
gute\_alert.\_y = 334.5;  
};  
[/AS]

* * *

Stuff.as is the same like Club and Gute, only that instead of club or gute i stuff.

Here is the PHP code for the home, and club(the gute and stuff are the same, instead of club i have gute and stuff, and the link of the text input area and variable are ok)  
Home.php

```php

<?PHP

$text = $_POST['input_home_text'];
$fol = fopen ("home.txt",w);
$sentOk = fwrite ($fol,"home=".$text);

?>

```

* * *

Club.php (submit\_club.php)

```php

<?php
//CLUB PHP SCRIPT//

//Variabile Flash.
$locatie = $_POST['town'];
$nume = $_POST['name'];
$url = $_POST['link'];
$id = $_POST['id_update'];

//Variabile Locale.
$username = "root";
$password = "";
$database = "electrotown";

//Connectare la Database.
$connect = mysql_connect("localhost",$username,$password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database);

//Updatare Database.
$update = "UPDATE club SET oras = '$locatie', nume = '$nume', link ='$url' WHERE id = '$id'" or die(mysql_error());
mysql_query($update);

//Scriere XML.
$query = mysql_query("SELECT * FROM club ORDER BY id ASC");

$xml = "<data>
";

while ( $i = mysql_fetch_array($query)) {

$xml = $xml . " <row>
";
$xml = $xml . " <id>";
$xml = $xml . $i['id'];
$xml = $xml . "</id>
";

$xml = $xml . " <oras>";
$xml = $xml .$i['oras'];
$xml = $xml . "</oras>
";

$xml = $xml . " <nume>";
$xml = $xml .$i['nume'];
$xml = $xml . "</nume>
";

$xml = $xml . " <link>";
$xml = $xml .$i['link'];
$xml = $xml . "</link>
";

$xml = $xml . " </row>

";

}
$xml = $xml . "</data>";

$fol = fopen("club_db.xml",w);
$fold = fwrite($fol,$xml);

//Scriere mesaj.
echo "<center><font size = 3>Datele au fost updatate cu succes in:<b> ".$database."</b>.</font></center><br>";
echo "<center>Datele: <b>".$locatie." </b>, <b>".$nume."</b> , <b>".$url."</b> au fost updatate in database-ul: <b>".$database."</b>.</center>";
//Inchidere XML si Database.
fclose ($fol);
mysql_close($connect);

?>
<script language="javascript">
window.close();
</script>

```

* * *

Club.php (update\_club.php)

```php

<?php
//CLUB PHP SCRIPT//

//Variabile Flash.
$locatie = $_POST['town'];
$nume = $_POST['name'];
$url = $_POST['link'];
$id = $_POST['id_update'];

//Variabile Locale.
$username = "root";
$password = "";
$database = "electrotown";

//Connectare la Database.
$connect = mysql_connect("localhost",$username,$password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database);

//Updatare Database.
$update = "UPDATE club SET oras = '$locatie', nume = '$nume', link ='$url' WHERE id = '$id'" or die(mysql_error());
mysql_query($update);

//Scriere XML.
$query = mysql_query("SELECT * FROM club ORDER BY id ASC");

$xml = "<data>
";

while ( $i = mysql_fetch_array($query)) {

$xml = $xml . " <row>
";
$xml = $xml . " <id>";
$xml = $xml . $i['id'];
$xml = $xml . "</id>
";

$xml = $xml . " <oras>";
$xml = $xml .$i['oras'];
$xml = $xml . "</oras>
";

$xml = $xml . " <nume>";
$xml = $xml .$i['nume'];
$xml = $xml . "</nume>
";

$xml = $xml . " <link>";
$xml = $xml .$i['link'];
$xml = $xml . "</link>
";

$xml = $xml . " </row>

";

}
$xml = $xml . "</data>";

$fol = fopen("club_db.xml",w);
$fold = fwrite($fol,$xml);

//Scriere mesaj.
echo "<center><font size = 3>Datele au fost updatate cu succes in:<b> ".$database."</b>.</font></center><br>";
echo "<center>Datele: <b>".$locatie." </b>, <b>".$nume."</b> , <b>".$url."</b> au fost updatate in database-ul: <b>".$database."</b>.</center>";
//Inchidere XML si Database.
fclose ($fol);
mysql_close($connect);

?>
<script language="javascript">
window.close();
</script>

```

* * *

Club.php (delete\_club.php)

```php

<?php
//CLUB PHP SCRIPT//

//Variabile Flash.
$id = $_POST['id_remove'];

//Variabile Locale.
$username = "root";
$password = "";
$database = "electrotown";

//Connectare la Database.
$connect = mysql_connect("localhost",$username,$password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database);

//Stergere ID din Database.
//"DELETE FROM gute WHERE id = '$id'" or die(mysql_error());
$delete = "DELETE FROM club WHERE id = '$id'" or die(mysql_error());
mysql_query($delete);

//Scriere XML.
$query = mysql_query("SELECT * FROM club ORDER BY id ASC");

$xml = "<data>
";

while ( $i = mysql_fetch_array($query)) {

$xml = $xml . " <row>
";
$xml = $xml . " <id>";
$xml = $xml . $i['id'];
$xml = $xml . "</id>
";

$xml = $xml . " <oras>";
$xml = $xml .$i['oras'];
$xml = $xml . "</oras>
";

$xml = $xml . " <nume>";
$xml = $xml .$i['nume'];
$xml = $xml . "</nume>
";

$xml = $xml . " <link>";
$xml = $xml .$i['link'];
$xml = $xml . "</link>
";

$xml = $xml . " </row>

";

}
$xml = $xml . "</data>";

$fol = fopen("club_db.xml",w);
$fold = fwrite($fol,$xml);

//Scriere mesaj.
echo "<center><font size = 3>ID-ul:<b> ".$id."</b> a fost sters din Database.</font></center><br>";
//Inchidere XML si Database.
fclose ($fol);
mysql_close($connect);

?>
<script language="javascript">
window.close();
</script>

```

* * *

When access a page (club\_mc for exemple) and i write something everything goes ok, BUT when i access the second page (gute\_mc) and i write something and i click SUBMIT the PHP is opened in a new window (this is ok) but nothing is writen down in the database, then the site is crashed!!!

Can you help me, you can see the exemple here:  
[http://www.electrotown.de/test](http://www.electrotown.de/test)

Thank you in advanced, Tiberiu!

---

<div class="post-metadata">

**Author:** ![btibia](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/btibia/32/1625_2.png) [@btibia](https://forum.kirupa.com/u/btibia)\
**Post date:** [April 4, 2006, 2:51pm UTC](https://forum.kirupa.com/t/as-php-mysql-something-big-can-you-help-me/184341/2 "2006-04-04T14:51:02Z")

</div>

I think nobody can help me with this!!! :(:(:(☹

---

<div class="post-metadata">

**Author:** ![btibia](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/btibia/32/1625_2.png) [@btibia](https://forum.kirupa.com/u/btibia)\
**Post date:** [April 5, 2006, 10:03am UTC](https://forum.kirupa.com/t/as-php-mysql-something-big-can-you-help-me/184341/3 "2006-04-05T10:03:14Z")

</div>

I have discovered that the actionscript + php + mysql workes perfect when they are in different files, if i load into my main movie, in a container movieClip, this .swf do you think i will have problems with variables definitions?(i see that i have the upper problem because the flash doesn’t now to update the variables). Do you think this will resolve the problem?
