Welcome, Guest. Please login or register.
Did you miss your activation email?
05/23/12, 00:30
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  MySQL, PostgreSQL, MS SQL, Access (Moderators: Flash-db, Musicman, Ronald Wernecke, Jorge Solis, Andries Seutens)
| | |-+  My last hope...{mySQL}
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: My last hope...{mySQL}  (Read 2884 times)
Jonathan
Server what's that
*
Posts: 3



View Profile Email
« on: 03/27/02, 16:41 »

Hi,

I just can't believe how little help there's out there for Flash & mySQL support. This site is the best one I've found by far.....in 3 very loooong days!

I currently have a webserver with mySQL and I wanted to know how to display the data in Flash without using PHP. I'd be happy to use Perl though.

Does anyone know of any full examples or tutorials where I can build sample Flash to access mySQL? All I need is examples to work from, but any help would be great.

Your help would be so appreciated, I just can't put it into words...sniff sniff....

Cheers people,

Jon
Email: jblazini36@hotmail.com

PS: Forgot to mention...I'm rusty at Flash so please be gentle.
Logged
Flash-db
Administrator
Systems Administrator
*****
Posts: 1867



View Profile WWW
« Reply #1 on: 03/27/02, 17:34 »

A connection with Perl:

#!/usr/bin/perl -w

use DBI;
use strict;

my $DBName = "(your database name)";
my $DBUser = "(your database user name)";
my $DBPass = "(your database password)";
my $DBHost = "localhost";

my $dsn = "DBI:mysql:$DBName;$DBHost";
my $dbh = DBI->connect($dsn, $DBUser, $DBPass);

if ( !defined $dbh )
{
print "Status=Failure";
exit;
}
else
{
print "Status=Success";
}

$dbh->disconnect;



Well normally you would have a bunch of SQL queries in their.  The out put though is always the same for Flash no matter what type of database or script you are using.  Basically the end product of all your queries and code have to have a certain format.

For example the final output that is printed to the browser screen has to look like this:

Var1=Value1&Var2=Value2......

Then in your flash movie you would have a dynamic text field named Var1 - if the script was executed successfully - the value for Var1 (Value1) would be sent back to the Flash movie and it would appear in that text area.

- You can also send Variables to the Script you are using from the flash movie and have the script execute a MySQL query based on the data that was sent to it from the Flash movie.  

Once you start trying small examples and get away from thinking that everything has to be returned and formatted as html - and start thinking  Var1=Value1&Var2=Value2.. as what you want returned it will become much easier.
Logged

-Jeff.
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #2 on: 03/27/02, 17:51 »

Hi,

try to read "man DBI"...
A perl script to read some data from a database looks like that

use DBI;
$dbh = DBI->connect('dbi:mysql:database=databasename', 'user', 'pass');
$aryref = $dbh->selectall_arrayref("select * from table");
$cnt = $#$aryref;
for($n = 0 ; $n <= $cnt ; $n++)
{ $row = $$aryref[$n];
 $item1 = $$row[0]; $item2 = $$row[1];

}
$dbh->disconnect;

Musicman
Logged
Jonathan
Server what's that
*
Posts: 3



View Profile Email
« Reply #3 on: 03/28/02, 06:18 »

Thanks guys.......I'll start some R&D now........
Logged
Jonathan
Server what's that
*
Posts: 3



View Profile Email
« Reply #4 on: 03/28/02, 06:22 »

Wait a minute.....I'm ok with doing the Perl....but how do I call the script from Flash?
Logged
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #5 on: 03/28/02, 14:57 »

Hi,

it is the same for all backend languages - lodvariables may optionally send data to the script and returns data to the movie
- loadmovie may optionally send data to a script but expects a flash movie back

Musicman
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!