Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 27th, 2002, 12:14 PM
esposito esposito is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 20 esposito User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Lightbulb Interaction between PHP, MySQL and Macromedia Flash MX

Hello, I have recently started to study Macromedia Flash MX and found it ideal for the creation of very impressive graphic intefaces. Unfortunately, its inability to save data either on the hard disk or on a server is a serious problem preventing the creation of any database whatsoever.

As soon as I learned that Flash can interact with PHP and, through this programming language, manage MySQL databases, I searched for tutorials which could explain to me how to do that.

My search was only partially successful, in that I could only learn how to query a database by means of a PHP file "launched" by Flash and get the results of the query within Flash.

To sum up, I created a simple frame in Flash containing a button and a textbox accepting HTML code. Then I assigned the variable name "Results" to the textbox and inserted the following code in the on_release event of the button:

//***START OF CODE***
on (release) {
loadVariablesNum("getfile.php",0);
}
//***END OF CODE***

The code above allows Flash to execute the "getfile.php" file containing the following code:

//***START OF CODE***
<?php

@mysql_connect("localhost", "root", "") or die ("Failed to connect!");
@mysql_select_db("contacts") or die ("Could not open DB");

$result1 = mysql_query("select * from customers");

print "Results=";
echo "<h1>Search Results</h1><br>";

while($row=mysql_fetch_array($result1))
{
$nome=$row["name"];
echo "<b>Name: </b>$name<br>";

$phone=$row["phone"];
echo "<b>Phone number: </b>$phone<br><br>";
}

?>
//***END OF CODE***

As you know, the line
print "Results=";
inserts the expression "Results=" at the beginning of the output generated by PHP, so that Flash can import such output into its textbox called "Results".

So far, so good. What is still unclear to me is how to send the content of a textbox from Flash to PHP. This would allow me to create the graphic interface of a database in Flash and pass the data to PHP. Finally, PHP would take care of inserting this data into a MySQL database.

What I really need is simply to learn how to translate the following PHP instructions into Flash code:

$variabile = $_POST['textbox'];
echo "$variabile";

Of course, the code above belongs to a form in which the method property is set to "post". Nevertheless, the textbox sending the data should belong to Flash rather than an HTML form. If I managed to do that, I could easily save the data sent by Flash in a MySQL database.

I have installed PHP v.4.2.3 on a Windows XP Home Edition system equipped with an Apache HTTP Server v.1.3.24 and MySQL v.4.0.3.

Thanks in advance for your help.

Pasquale Esposito
Perugia (Italy)
http://web.tiscali.it/espositopasquale/

Reply With Quote
  #2  
Old December 30th, 2002, 03:50 PM
ddlam ddlam is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Hong Kong
Posts: 31 ddlam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
Send a message via ICQ to ddlam
Assume that you have a variable call "var1" on _root and its value is "100".
loadVariablesNum("*.php?abc=" + var1, 0);

*.php
PHP Code:
echo "the result is:$abc";//the result is:100 
__________________
A green newbie in PHP

Last edited by ddlam : December 30th, 2002 at 03:52 PM.

Reply With Quote
  #3  
Old December 31st, 2002, 09:06 AM
esposito esposito is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 20 esposito User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks: Problem solved!

Dear ddlam.

thanks for your help but I had already found the solution to my problem. Now I know that to send data from a textbox in Flash

MX to a PHP file, it is enough to use the method

loadVariablesNum("myfile.php", 0, "POST");

Then, inside the PHP file, I must recall the Flash variable in the following way:

//***START OF CODE***
<?php

//Retrieves variable from Flash
$myvar = $_POST['textbox'];

//varDisplay is the variable name assigned to the Flash textbox
echo "varDisplay=The user typed in this expression: ";
echo "$myvar";

?>
//***END OF CODE***

Thanks again.

Pasquale Esposito
Perugia (Italy)
http://web.tiscali.it/espositopasquale/

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > Interaction between PHP, MySQL and Macromedia Flash MX

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap