PDA

View Full Version : Simple Flash>PHP>MYSQL


MrJ
07-30-2007, 01:02 PM
I've been looking through the web all weekend, and all I can find is how to receive variables from a MySQL DB, or some type of guestlist, etc.. Basically I have a form with two fields: Full Name and Email. I knows it simple because I did it back during MX 2004, I just forgot. :p

Now I am using CS3 with phpMyAdmin, and here is my code:

Actionscript for Regster button:


on (release) {

var myVar = new LoadVars();
myVars.clientname = clientname.text;
myVars.uemail = email.text;
myVars.SendandLoad("glsitadd.php",myVars,"POST");
gotoAndStop(2);


}


And my PHP Code:

<?php
$connection = mysql_connect("serveraddy goes here",
"dbusername goes here",
"dbpassword goes here");
mysql_select_db("EmailL", $connection);

$name=$_POST['clientname'];
$email=$_POST['uemail'];

$sql = 'INSERT INTO `EmailL`.`Email` (`name` ,`email` )VALUES ($name, $email);';

mysql_query($sql);

?>



Thanks!

Cota
07-30-2007, 07:15 PM
What do you want to do exactly?

MrJ
07-30-2007, 08:49 PM
I have two text boxes in my flash movie, one is the name, other for email address. I just want to have the values sent the database.

Btw, I read one of your Actionscript 3 intro tutorials, great job!

Cota
07-30-2007, 09:55 PM
$sql = "INSERT INTO `tableNameOnly` (`name` ,`email` )VALUES ('$name', '$email')";
//TableNameONly is replaced with your table name.


And you may have me confused with someone else, I havent written anything for AS3.

MrJ
07-31-2007, 03:44 PM
$sql = "INSERT INTO `tableNameOnly` (`name` ,`email` )VALUES ('$name', '$email')";
//TableNameONly is replaced with your table name.


And you may have me confused with someone else, I havent written anything for AS3.

Still didn't work, I'm going to try to trace my variables. Btw, the form is a movie inside a movie, so should be I using this.variable?

Cota
08-01-2007, 12:26 AM
with sendAndLoad you also have to send back a dummy variable from PHP, so you can just add

echo "&dummy=1&";

MrJ
08-02-2007, 01:18 PM
var myVar = new LoadVars();



I removed the var from the beginning, fixed some typos in the instance names and that worked.

Thanks for your assistance!

Cota
08-03-2007, 02:11 AM
typos will kill you everytime. They still kill me. If you were having issues with this line

var myVar = new LoadVars();

then you may be saving it as an AS1 document. Make it AS2 and that wont give you issues.