A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [CS3] Need help in passing flash variable to PHP to Data base

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    2

    [CS3] Need help in passing flash variable to PHP to Data base

    Hi I am new to flash and php coding,here is my code I am not able to find error in the flash & php code and its not showing any error in browser ,not updating to database.IF some one can help me out ,Its greatly appreciated.

    on(release)
    {


    var myVars:LoadVars = new LoadVars();
    var result_lv:LoadVars = new LoadVars();
    myVars.firstname = this._parent.txtFirstname.text;
    myVars.lastname = this._parent.txtLastName.text;
    myVars.company = this._parent.txtCompany.text;
    myVars.email = this._parent.txtEmail.text;
    myVars.city = this._parent.txtCity.text;
    myVars.country = this._parent.txtCountry.text;


    //myVars.load("SetDetails.php", myVars, "POST");
    //getURL("SetDetails1.php",myVars, "POST");
    //myVars.send("SetDetails.php",myVars,"POST");

    myVars.sendAndLoad("SetDetails1.php", result_lv, "POST");

    result_lv.onLoad = function(success)
    {
    if (success)
    {
    if(userIn.qstatus=="passed")
    {

    msgbox.text = "Successfully Submitted";
    }
    }
    else
    {
    msgbox.text = "nope";
    }
    }
    txtFirstname.text = "";
    txtLastName.text = "";
    txtCompany.text = "";
    txtEmail.text = "";
    txtCity.text = "";
    txtCountry.text = "";

    //loadVariablesNum("SetDetails.asp",0,"post");
    }

    //My PHP Code

    PHP Code:
    <?php

         import_request_variables
    ("myVars");
        
    //Connect To Database
        
    $hostname='localhost';
        
    $username='xxxxxxxxx';
        
    $password='xxxxxxxxx';
        
    $conn mysql_connect($hostname$username$password) OR DIE('Unable to connect to database! Please try again later.'.mysql_error());
        
    mysql_select_db('thresholdassetsdatabase') or die('could not select database'.mysql_error());

     
    //stores the URLvariables into variables that php can use
    $FirstName $_POST['firstname']; 
    $LastName $_POST['lastname']; 
    $Company$_POST['company']; 
    $Email $_POST['email']; 
    $City $_POST['city'];
    $Country $_POST['country']; 

     echo 
    "$FirstName";
     echo 
    "$LastName";
     echo 
    "$Company";
     echo 
    "$Email";
     echo 
    "$City";
     echo 
    "$Country";
     
    //this is the command used to write the record into the MySQL database
    $query="INSERT into newsletter_emails_imade ('FirstName', 'LastName','Company','Email','City','Country') VALUES ("%$FirstName%", "%$LastName%", "%$Company%", "%$Email%", "%$City%", "%$Country%")";   
     
    //executes the command
    mysql_query($query) or die("Data not written.");
    echo(
    "The data has been written to the table!");
    if(
    qstatus){
    echo 
    "&qstatus=passed";
    }else{
    echo 
    "&qstatus=falied";

    mysql_close($conn);

    ?>

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    Your PHP code is full of errors, try this:
    PHP Code:
    <?php
    //Connect To Database
    $hostname    'localhost';
    $username    'xxxxxxxxx';
    $password    'xxxxxxxxx';
    $conn        mysql_connect($hostname$username$password) or die('&qstatus=Unable to connect to database! Please try again later: '.mysql_error());
    $select        mysql_select_db('thresholdassetsdatabase') or die('&qstatus=could not select database: '.mysql_error());

    $FirstName    mysql_real_escape_string($_POST['firstname']);
    $LastName    mysql_real_escape_string($_POST['lastname']);
    $Company    mysql_real_escape_string($_POST['company']);
    $Email        mysql_real_escape_string($_POST['email']);
    $City        mysql_real_escape_string($_POST['city']);
    $Country    mysql_real_escape_string($_POST['country']);

    $query "INSERT into newsletter_emails_imade ('FirstName', 'LastName','Company','Email','City','Country')
                VALUES ('"
    .$FirstName."', '".$LastName."', '".$Company."', '".$Email."', '".$City."', '".$Country."');";   

    $result mysql_query($query) or die("&qstatus=Data not written");

    if(
    $result)
    {
        echo 
    "&qstatus=passed";
    }else{
        echo 
    "&qstatus=falied";
    }

    mysql_close($conn);
    ?>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center