Page 1 of 1

intergrating with flash (actionscript)

Posted: Wed Nov 23, 2005 2:18 pm
by amrik1984
twigletmac | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

am pretty much an ameture at flash and php. based on the save movie position tutorial that some of you have may have seen, i have created 2 php files that gets data from the mysql files and inserts it into a flash file, well, trying to anyway

its a very simple file

i am basically asking to spot the errors if you can see any

the file runs of my localhost, im not sure how to load the actual files up so ive just copied the code from each file onto here. 

the mysql file contains just 2 fields
- id (unique id)
- telno

here is the first php file


CODE

Code: Select all

<?


$DBhost = "localhost";
$DBuser = "";
$DBpass = "";
$DBName = "insurance";
$table = "contact";

?>
then the login php

Code: Select all

require 'include2.php';

// Connects to the database.
mysql_connect($DBhost,$DBuser,$DBpass);
mysql_select_db("$DBName");

// The SQL query
$query = "SELECT * FROM $table WHERE id = '$id'";
$result = mysql_query($query);

/* This just gets the number of rows in the Query - It's just a check to see if the Name exists - If not it prints out an error statement. */
$numR = mysql_num_rows($result);

// If the number of rows is not equal to one then it prints out an error statement - Name not in Database.
    
    if ($numR == 1) { 
    print "Status=Success Login Complete&CheckLog=1";
    }
    else {
    print "Status=Failure - Your name was not found - Please register"; 
    }

?>
then finally the register(loadining) php file


CODE

Code: Select all

<?php
// The registration script adds a record to the SQL database with the user's Name. That's about it.

// This first line of Code is to load your database variables.
require 'include2.php';

// Connects to the Database.
mysql_connect($DBhost,$DBuser,$DBpass);
@mysql_select_db("$DBName");

//selects "id" from  the database

$result = mysql_query("SELECT * FROM $contact WHERE id = '$id'");

//This sets the variables from the Database
     $id = mysql_result($result,0,"id");
     $telno = mysql_result($result,0,"telno");
    
/* This next bit prints out the value's of the Comment and the positions of the three objects whose properties you want to save. This is the line that Flash will read into the movie. */

print "$telno";

?>
then the flash file

frame 1

Code: Select all

stop ();
frame 2

Code: Select all

// if checklog (from login3.php) has a value, go to frame 6
//otherwise go to frame 2

//just to make sure login.php was succesful at loading
if (CheckLog ne "") {
    gotoAndPlay (6);
} else {
    gotoAndPlay (2);
}
frame 4

Code: Select all

loadvairablesnum ("register2.php?id="+id, 0);
gotoandplay (6);
frame 6

Code: Select all

//if there is a value for id, enter it into texttel.text

if (id ne "") {
    texttel.text = ("telno");
}
else{
    gotoandplay (1);
}
and the button of the movie

Code: Select all

on (release) {

    if (Name ne "") {
    gotoAndPlay(2);
    Status = "Beginning Login Process.. Please Hold";
    //The next line calls the Login.php script. And returns the results from it to the movie.
    loadVariablesNum ("Login2.php?id="+id+"&R="+random(999), "0");
    }
    else {
    Status = "Please enter a User Name";
    }
    
}
thanks

Posted: Thu Nov 24, 2005 8:26 am
by n00b Saibot
looks fine to me as far as I can see. Consider using PHP and CODE tags when posting code...

Posted: Thu Nov 24, 2005 8:45 am
by neophyte
You miss spelled "loadVariablesNum();"
loadvairablesnum ("register2.php?id="+id, 0);
I suggest when you print your variable:
print $telno;
It needs to be formated like:

Code: Select all

&var1=somestring1&var2=somestring2&

Make sure there are ampersands before and after the variables.

Hope this helps.

Take a look at the functions sendAndLoad(); It's a much better way IMHO of importing and sending data to another page.

Posted: Thu Nov 24, 2005 8:59 am
by n00b Saibot
neophyte wrote:You miss spelled "loadVariablesNum();"
loadvairablesnum ("register2.php?id="+id, 0);
I thought he must have misspelt it while posting here so I sorta let that go :)