Using databases with Flash and PHP
Hi, everyone!
I`m a PHP newbie. I just learned PHP so that I can use
databases with Flash.
I`ve got a .php script that contains html that loads up my
.swf file. The .swf file is the core of my site. What I want to
know is if I can call some PHP functions (that I have wrote in the
.php script) from within the .swf file... This functions would
perform the reading and updating of my database.
The only way I know of to modify a database from Flash is
using the POST and GET methods. But that opens up a new browser
window in which the PHP script is called. And that only handles
writing in the database. So, what if I just want to read from the
database some values and insert them into a TextField in Flash? How
do I do that?
Thanks! Ardy
1. Goggle "Flash and mySQL" and you'll get a listing of alot
tutorials
2. I'm also just learning. Here's a great URL to start:
Building with Flash and MySQL
That's right, a Flash-based blog — it sounds a little
loony, but this blog pulls content from a MySQL database and feeds
it into the dynamic Flash frontend ...
www.webmonkey.com/programming/php/tutorials/tutorial2.html -
20k - Cached -
Similar Messages
-
Populating a Combobox using Remoting with AMF and PHP
Hello all
I am using Zend framework and Flex 3.4 to create a webapp. I am stuck at how to populate a combobox dynamically using the service I created in PHP.
In some of examples I saw that result of database query was being converted into XML and then sent to Flex. This seems a little too time-consuming if I have to do it every time. I saw some examples in Adobe Docs about Remoting with AMF and PHP. That seems like a better approach although how it would be applicable here is beyond me right now.
Can somebody guide me in correct direction?
Thanks and Regards
ShivikTry this: http://code.google.com/p/as3flexdb/ is very easy to use and it
will help.
All you need to populate a combo is:
<mx:ComboBox dataProvider="{query.Records} / -
High Score Table: Writing a Simple Text File with Flash and PHP
I am having a problem getting Flash to work with PHP as I need Flash to read and write to a text file on a server to store simple name/score data for a games hi score table. I can read from the text file into Flash easily enough but also need to write to the file when a new high score is reached, so I need to use PHP to do that. I can send the data from flash to the php file via POST but so far it is not working. The PHP file is confirmed as working as I added an echo to the file which displayed a message so I could check that the server was running PHP - the files were also uploaded to a remote server so I could test them properly. Flash code is as follows:
//php filewriter
var myLV = new LoadVars();
function sendData() {
//sets up variable 'hsdata' to send to php
myLV.hsdata = myText;
myLV.send("hiscores.php");
I believe this sends the variable 'myText' to the php file as a variable called 'hsdata' which I want the php file to write into a text file. The mytext variable is just a long string that has all the scores and names in the hiscore. OK, XML would be better way of doing this but for speed I just want to get basic functionality working, so storing a simple text sting is adequate for now. The PHP code that reads the Flash 'hsdata' variable and writes it to the text file 'scores.txt' follows:
<?php
//assigns to variable the data POSTed from flash
$flashdata = $_POST["hsdata"];
//file handler opens file and erases all contents with w arg
$fh = fopen("scores.txt","w");
//adds data to file
fwrite ($fh,$flashdata);
//closes file
fclose ($fh);
echo 'php file is working';
?>
Any help with this would be greatly appreciated - once I can get php to write simple text files I should be ok. Thanks.Thanks for your help.
I have got Flash working to a certain extent with PHP using loadVars but have been unable to get flash to receive a variable declared in PHP. Here's my Flash code:
var outLV = new LoadVars();
var inLV = new LoadVars();
function sendData() {
outLV.hsdata = "Hello from Flash";
outLV.sendAndLoad("http://www.mysite.com/hiscores/test23.php",inLV,"post");
inLV.onLoad = function(success) {
if (success) {
//sets dynamic text box to show variable sent from php
statusTxt.text = phpmess;
} else {
statusTxt.text = "No Data Received";
This works ok and the inLV.onLoad function reports that it is receiving data but does not display the variable received from PHP. The PHP file is like this:
<?php
$mytxt =$_POST['hsdata'];
$myfile = "test23.txt";
$fh = fopen($myfile,'w');
//adds data to file
fwrite($fh, $mytxt);
//closes file
fclose ($fh);
$mess = "hello there from php";
echo ("&phpmess=$mess&");
?>
The PHP file is correctly receiving the hsdata from flash and writing it to a text file, but there seems to be a problem with the final part of the code which is intended to send a variable called 'phpmess' back to Flash, this is the string "hello there from php". How do I set up Flash and PHP so that PHP can send a variable back to Flash using echo? Really have tried everything but am totally baffled. Online tutorials have given numerous different syntax configurations for how the PHP file should be written which has really confused me - any help would be greatly appreciated. -
How to use non-MySQL database with DW and PHP...???
I need to connect to a data-source that is not MySQL from
with my PHP scripts. The only option I get under the Databases tab
in the Application panel is MySQL Connection. What about just
standard ODBC connections? Will DW not handle those for me? Do I
have to do all of that by hand??
Any information would be greatly appreciated. Thanks!"Angell EYE" <[email protected]> wrote in
message
news:fc4eaj$fmn$[email protected]..
>I need to connect to a data-source that is not MySQL from
with my PHP
>scripts.
> The only option I get under the Databases tab in the
Application panel is
> MySQL
> Connection. What about just standard ODBC connections?
Will DW not
> handle
> those for me? Do I have to do all of that by hand??
>
> Any information would be greatly appreciated. Thanks!
There once existed an opensource servermodel called phakt
that used the
ADODB database abstraction library,
the company that created and supported it was bought by Adobe
and
subsequently the project was cancelled.
A group of people (including me) started a community
initiative@
http://openphakt.sourceforge.net
to continue distribution and development of
phakt, but unfortunately I don't have access to Dreamweaver
CS3 due to lack
of funding.
Phakt will almost certainly NOT run on CS3 in it's current
state, but is
should support previous versions.
Joris -
Help with flash and php prlblem
the problem is flash receive the data back after send
loadvars.but it always got it wrong.
code in flash is:
send_btn.onRelease = function() {
myVars = new LoadVars();
myVars.username = username_txt.text;
myVars.phonenum = phonenum_txt.text;
myVars.picktime = picktime_txt.text;
myVars.email = email_txt.text;
myVars.address = address_txt.text;
myVars.shortmessage = shortmessage_txt.text;
myVars.onLoad = function(success) {
if (success) {
if (this.order) {
gotoAndStop(2);
} else {
gotoAndStop(3);
delete myVars;
myVars.sendAndLoad("sendorder.php", myVars, "POST");
and code in php is:
$username = $_POST['username'];
$phonenum = $_POST['phonenum'];
$picktime= $_POST['picktime'];
$email = $_POST['email'];
$address = $_POST['address'];
$shortmessage= $_POST['shortmessage'];
$result=mysql_query("insert into
userinfo(email,username,phonenum,address,picktime,message)
values('$email','$username','$phonenum','$address','$picktime','$shortmessage')");
if($result){
echo "order=1";
}else{
echo "order=0";
flash reponse after receiving the varaible from php is always
go to frame 3
but the test of php is output order=1.
what is wrong with it?please help::^_^interesting b, but i think i see something else here that is
the reason you needed to add the '&'. You're passing back a
number value (ie. 0/1) and treating it as a boolean (all fine)
except that in the echo statement it's all inside quotes, so it's
being interpreted as a complete String. to remedy, try writing the
echo like this:
if($result) {
echo('order='.1);
}else{
echo('order='.0);
and you're welcome :) -
How to connect sql database with Flash
Dear Friends,
Iam working on a quessinarie (assesment) for elearning software. i want to connect sql database with flash and save my records in back end like add, delete, modification of student result and details.
Kindly help me to connect the sql database. or dot net server. I know how to connect PHP and mysql. But my client dont want php. only sql database and do the add, del, modificaiton.
Thanks in advance,
Syed Abdul Rahimunfortunately no, i do not know ASP well enough to give any code advice, other than the basic concept: make a request on a server-side script (such as ASP) via URLLoader - the script receives variable values (if required), runs the DB queries you wish to invoke, and 'returns' the results - pick them up in the URLVariables class via the event handler in Flash and assign them to local properties if needed, etc.
there are quite a few threads that you could find more specific information on the ASP side, here and elsewhere around the net. -
Array data between Flash and PHP
As the title suggests, I'm trying to find a good way of
getting an ActionScript/Flash dynamic array into PHP, so I can
serialize it and store it in a DB, then simply give back that same
array when it's called. Are there any popular techniques? The array
will always be a different size, containing different values -
which is why I'd like to keep the array in tact, to minimise the
amount of parameter transfers. If there's no good solution, I
suppose I could pass in parameters and read them in, create an
array and serialize that... but I'd much rather find a way of
having my flasher serialize his own array and pass me the
byte-code. Is this possible?
PHP doesn't need to read the contents of the array, simply
store it in a DB, so if there's some kind of flash method for
serializing an array into bytecode that it can unserialize and read
back later, that would be awesome.
Thanks. =]
[edit]
I found this:
http://sourceforge.net/projects/serializerclass/
a serializer class. Is this the best method?Sorry, I should have explained, we already use XML for data
transfers (though I personally find JSON much nicer with less
overhead). So, in this project, we use XML for data transfer
between flash and PHP/Database. The reason I wanted this
functionality, is because the flash array, in this one case, will
be completely dynamic and the PHP doesn't need to know the contents
of the array at all. In fact, in this instance, PHP is just the
mechanism used for storing the data. Becuase of the nature of the
data, I wanted to serialize the flash array, store it in the
database as Bytecode, then when the flash needs that information
again, I can pass back the same bytecode, which can then be
unserialized back into the original array.
I think I've found the solution, the one I linked in the
original post. I should know if it's as effective as I want it to
be in the next couple of days when my flasher gives it a try. =]
Thanks for the responses. If anyone has any other ideas,
please throw them in here. -
How can I link my database with flash?
Hi…
How can I link my database with flash to display image (to
display it in master details page)
Please your help ASAP.
Regards,You could use some server-side scripting like PHP or ASP.
http://www.kirupa.com/web/index.htm -
What's With Flash and IE7 ?
I have noticed a number of posting of Flash and IE7 troubles,
but they are not close enough or succinctly worded enough to suit
me to glom onto their post with my problem, and I noticed that the
ones who have a problem similar to mine are not being answered. So,
I take it that there is definitely a problem with Flash and IE7,
but no one knows the answer and Microsoft has not risen to the
problem of dealing with a problem that affects hundreds of
thousands of users. I have posted the following on a Microsoft
forum, but have received no reponses there as of yet. Hopefully the
Flash gurus here will be able to rise to the occasion more quickly
than their Microsoft IE counterparts.
If you look at the home page for
http://www.townofstarprairie.com/
using FireFox or IE 6 (with security settings lowered), you'll
notice a scrolling flash text box at the top, and an exact
duplicate of that text box at the very bottom of the page.
If you use IE 7, the one on top does not show but the one on
the bottom of the page does. These two Flash boxes are identical in
every way.
I have toyed with my IE 7 settings to the point where IE was
screaming at me that the world was going to come to an end due to
my low security settings, and still the one on top does not show.
What ever could be the problem with this?
Thank you for any help you can provide!Nickels55, you are correct....mostly.
One of my acquaintances busted into the weather.com code and
sent me the source. After much trial and error, I found that by
removing the STYLE block completely, I no longer had a problem. I
even tried removing the styles between the STYLE block, but that
didn't work. I had to remove the STYLE tags, too. I tried linking
out to a style page to no avail , btw.
For a while, you can see a bust of this problem at
http://www.townofstarprairie.elitecyberdesign.com/index.cfm?optionid=5877
What's really weird is that this problem only affects the
Flash code ABOVE the Weather.com widget (you would think it would
affect below, but such is not the case), and only in IE 7.
Very strange. -
Hi guys Pls tell me a way to connect db4 database with jsp and which driver
hi guys
Pls tell me a way to connect db4 database with jsp and
also tell me which driver i have to use
also tell me how to connect with excel sheetstake a look at the follwing links. There, you'll find all what you need :
DB4:
http://www.oracle.com/database/berkeley-db/je/index.html
http://www.oracle.com/technology/products/berkeley-db/je/index.html
http://www.oracle.com/database/berkeley-db/db/index.html
http://www.oracle.com/database/docs/berkeley-db-je-datasheet.pdf
Excel:
http://64.18.163.122/rgagnon/javadetails/java-0516.html
Hope That Helps -
I'm new with flash and don't know why the timers don't work like i would expect. In VB.NET timers are how you move stuff, but it doesn't look like they are ideal for moving stuff in flash at all (really slow). I'm making a game in which you throw a ball around the screen. i am using a timer to get the ball to move. this doesn't work well for 2 reasons; 1: the ball jumps alot, and 2: the timer should eventually run out of time. If anyone can help, i'd be thrilled cus this is my first post here, so yeah
Timing for movement would be more often dealt with using something that operates at the frame rate of the file. The ENTER_FRAME event is usually selected for this purpose.
stage.addEventListener(Event.ENTER_FRAME, moveBall);
function moveBall(evt:Event):void {
// your positioning code
You could use a Timer to control when to stop the listener from being active. -
Need Urgent Help with Apache and PHP
I have been struggling with apache and php for a week now and I finally broke down to post a message.
I have apache 1.3 running on my mac mini g4 with 10.4.9 and I installed sql. I went to the entropy website and downloaded php5 to install without knowing I already had php4 on the machine. I installed 5 but could not get it to work. I then went back to httpd.conf and tried to install php4 by uncommenting out the loadmodule and addmodule lines. I restarted apache but php still did not work. I tested the phpinfo.php script but all I got was the script in Safari and not the actual page. At the moment, I have php4 and php5 on my machine but can't get either one to work. I am sure there is an easy fix but I don't know it. Please help.The problem is not terribly complicated, but Apache will not start with the entropy file in the folder
/etc/httpd/users/
Let me experiment on you. Rename the entropy file and then try to start Apache. To do this, open Terminal and paste this command:
<pre>sudo mv /etc/httpd/users/+entropy.conf /etc/httpd/users/+entropy<pre>
Now check the Apache configuration:
<pre>apachectl configtest<pre>
If it says "Syntax OK", start Apache:
<pre>sudo apachectl start<pre>
Since we only disabled the entropy file, you should be able to enable PHP5 with some more advanced configuring. -
Any Problems using SSL with Safari and the move with Internet explorer to require only TLS encryption.
Hi .
Apple no longer supports Safari for Windows if that's what you are asking > Apple apparently kills Windows PC support in Safari 6.0
Microsoft has not written IE for Safari for many years. -
I have tearing with flash and Youtube videos.
First, my specs.
Windows XP
Quad Core
Nvidia 9600gt DDR3
2GB RAM
Browsers: Firefox 3.6.12 and IE7
I have the newest Nvidia Drivers and Adobe Flash 10.1
Well the problem is that I have tearing with flash and videos in Windowed Mode, if I turn the full screen option there is no sign of tearing BUT only if I have hardware acceleration turn on.
So the problem is, why I have tearing in windowed mode?Same here. I am not getting 'what tearing' is all about. Can u please explain?
-
Using url with username and password in URL class
Hi,
I'm writting an applet in which I use getAppletContext().showDocument with an URL.
The problem is that I'm using URLs with username and password (http://user:[email protected]/page) and it isn't working because the browser is getting the URL http://user/page.
Is this a bug in the URL class? Or in the showDocument method?
Is there any way to make this work?
Thanks for any help,
Pedro Prospero Luis ([email protected])I'm not sure whether this is supported behaviour. I've had this syntax fail to work in the Netscape address bar so I can't recommend it as an approach for authentication.
If you want to authenticate the user before redirecting to the page, though, you could try creating a connection to another page on the same server and sending the authorization information then. Your browser may then be successfully authenticated.
See http://www.javaworld.com/javatips/jw-javatip47.html for information on this.
You might not need to read back the page from the server, just connect to it. Might work.
Maybe you are looking for
-
How to get the Newly added fileds from Oracle to BW
Hi , We have created the view in the DB side and extracted the data to BW side. After that in the DB side they have added new filed. I want to extract the data for that filed also. But that filed is not displaying in the data source itself. We have d
-
when creating a reminder in reminders(IOS5) the "add location" is not available. I am using a 3gs Thnaks
-
Planned & actual production in REM
Hi expert, I need to display the gap between the Planned production & the actual production. Thanks in advance.
-
My T400 won't stay in sleep or hibernate after some update
Howdy.........a couple of weeks ago I applied some updates to my T400 through Thinkvantage maybe......honestly I don't remember. But it was recommended updates for my machine to things like Power Manager and Access Connections. After I did that, I'v
-
IMessenger on mac lion ??
this is just a question or possably a updat apple could consider if its not already out but..... is there a way to have imessenger on my macbook pro erly 2011 model so its not that far behind as it must be the only thing that hass not really got any