|
-
Who needs pants?
Send/Retrieve from a database to flash ?
Hey guys, was wondering if you could help me out. I have a project where i have a database containing all of the users of a particular application. The database contains the basic things usernames user paswords and other information specific to the flash file.
I havent done any work using a database and flash. So what i want to know is how do i set it up and what code do i use in my flash file to recieve information from the database and how do i save to the database?
Thanks in Advance
-
Hi,
first of all you will have to find something (php is a good candidate) on your server that lets you access the database - or, in case this is not on the web but on your local system, something that acts like a webserver
Musicman
-
Who needs pants?
Yep its online so its a web server.Going to be either asp or php. What do i need next ?
-
Who needs pants?
Does anyone have an opinion?
-
What kind of database is it?
I connect all the time using ASP and SQL
-
Hi,
sample database definition for mysql
create table users (
id int not null auto_increment,
user varchar(20),
password char(32) binary,
email varchar(80),
age tinyint, -- or whatever your fields are
primary key (id),
unique (user)
);
sample php script to add a new user
(flash form fields should be named user, password, etc like in the database; form should send POST method)
Code:
<?
include "db.php"; // include mysql password etc.
mysql_connect($DBHOST, $DBUSER, $DBPASS) or die("&status=cannot connect database server " . mysql_error());
mysql_select_db($DBNAME) or die("&status=cannot select $DBNAME database " . mysql_error());
$vars = array("user","password","email","age");
foreach($vars as $var)
$$var = $_POST[$var];
$status = @mysql_query("insert into users (user, password, email, age) values ('$user', md5('$password'), '$email', '$age')");
if(!$status)
if(mysql_errno() == 1062)
print "&status=duplicate value";
else
print "&status=problem inserting " . mysql_error());
else
print "&status=user added";
?>
For retrieving all users, you would usually choose either a flash tabular form or a textfield. For the multi-cell form, consider a php script like this
Code:
<?
include "db.php"; // include mysql password etc.
mysql_connect($DBHOST, $DBUSER, $DBPASS) or die("&status=cannot connect database server " . mysql_error());
mysql_select_db($DBNAME) or die("&status=cannot select $DBNAME database " . mysql_error());
$result = mysql_query("select * from users ...."); // the ... would later handle a search function
$n = 0;
while($row = mysql_fetch_array($result))
{ print "user$n={$row['user']}&email$n={$row['email']}&age$n={$row['age']}";
$n++;
}
print "&users=$n";
?>
Musicman
-
Who needs pants?
Thanks very much for that music man. Gonna read over it properly and try it out be waiting for questions
-
Who needs pants?
OK i dont know much about php i tried to understand what is probaly to you is very basic but to me im a little confused.
So basically i have
Flash File
PHP Page File
A database File
Ok ive got the flash file and data base business sorted but im having trouble managing the php page. Is their anyway you can help me out. I dont have any specific questions. Im just confused in general.
Do you mind just doing a algorithm of how the php file should work ?
Thanks in Advance
-
Who needs pants?
I just came across something that i think will be a problem.
In my flash file on the first frame i load the data to an empty mc.
serverData.loadVaribles("http://freshvision.com.au/data/db.php");
Does that load all the data my php page gathers from the database. Because my data base file has thousands of records. I dont want to load entire database files just records in the data base that match criteria in the flash file.
Like if the ID and PASSWORD feilds match in a row then send all information for that users ID and store them as seperate varibles in an empty mc.
Problem is the Php page and the loading entire database files problem.
Thanks again !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|