it's working fine, with mySQL and php. what i would like to do, is instead of it being a html page, make it a flash page. How do i get flash to talk to the database?
i tried to understand this but i'm finding it really difficult. i've got the php file working perfectly. i just need to get the swf to send the variables to the php file.
right, i'm using this php script:
<?
/*
insertscore.php: inserts record into kjsLaundry table, returns new
record id and status to Flash
*/
// fill with correct data for your server configuration
$server = "localhostt";
$username = "user";
$password = "password";
$database = "database";
if (!mysql_connect($server, $username, $password)) {
$r_string = '&errorcode=1&';
the insert score.php seems to be working because it's entering blank info into the database. but i can't work out how to get the swf to enter the info into the php. HELP!!!!
now i'm using this actionscript:
var send_lv:LoadVars = new LoadVars();
send_lv.name = name_ti.text;
send_lv.email = email_ti.text;
send_lv.address = address_ti.text;
stop();
//
with this on a button:
on (release) {
send_lv.send("http://localhost/insertscore.php", "_blank", "POST");
gotoAndPlay(2);
}
//
it seems to be sending something from the swf file, but then in the msql database for the entries it says undefined.
now i'm using this php code:
<?
/*
insertscore.php: inserts record into kjsLaundry table, returns new
record id and status to Flash
*/
// fill with correct data for your server configuration
$server = "localhost";
$username = "%";
$password = "%";
$database = "kjslaundry";
if (!mysql_connect($server, $username, $password)) {
$r_string = '&errorcode=1&';
here are the new files. if anyone could take a look at them and tell me what i'm doing wrong. i've managed to get the swf talking to the php, and the php talking to the mysql. but it's not entering what i am entering in the swf. it's just blank.
submit_button.onRelease=function(){
var result_lv:LoadVars = new LoadVars();
result_lv.onLoad = function(success:Boolean) {
if (success) {
result_ta.text = result_lv.welcomeMessage;
} else {
result_ta.text = "Error connecting to server.";
}
};
var send_lv:LoadVars = new LoadVars();
send_lv.name = "Joe";//name_ti.text;
send_lv.email = "joe@joe.net";//email_ti.text;
send_lv.address = "somewhere";//address_ti.text;
send_lv.sendAndLoad("http://localhost/insertscore.php", result_lv, "POST");
};
PHP:
Code:
<?
/*
insertscore.php: inserts record into kjsLaundry table, returns new
record id and status to Flash
*/
// fill with correct data for your server configuration
$server = "localhost";
$username = "root";
$password = "HEREJE";
$database = "test";
if (!mysql_connect($server, $username, $password)) {
$r_string = '&errorcode=1&';
}
else if (!mysql_select_db($database)) {
$r_string = '&errorcode=2&';
}
else {
$ins_str = "INSERT INTO maillist VALUES (NULL, '".addslashes($_POST['name'])."', '".$_POST['email']."', '".$_POST['address']."')";
if (!mysql_query ($ins_str)) {
$msg = mysql_error();
$r_string = 'errorcode=3&msg='.$msg;
} else {
// pass back id of inserted record
$id = mysql_insert_id();
$r_string = 'errorcode=0&id='.$id.'&';
}
}
echo "&welcomeMessage=This is what i get: ".$r_string;
?>
you never return the "welcomeMessage" variable, instead you returned "errorcode", i removed the "&" so flash will not read this as a variable, but a string
it all worked fine when i was using my computer as a webserver, but i've tried to upload it to my clients web server on easyhost and for some reason the web browser is reporting an error:
file not found: http://localhost/crossdomain.xml
this file isn't mentioned anywhere in the actionscript or php.