Jump to content

[SOLVED] Flash to PHP to Database, Variables not Inserting, any experts in this out there


Recommended Posts

Hi, does anyone see anything wrong with this code off hand?  I've tried many different ways and it still doesn't want to go into my database.  I quadruple checked the database name and info.  My best guess is that it's the variables.  Possibly the variables I am getting from Flash aren't posting correctly?  When I do a trace in Flash it says that the sendAndLoad is working.  Anyways let me get your thoughts if your interested.  Thanks.

 

<?php

$fname = $_POST['fname'];

$lname = $_POST['lname'];

        $cname = $_POST['cname'];

$address = $_POST['address'];

        $phone = $_POST['phone'];

$email = $_POST['email'];

$logo_yes_no = $_POST['logo_yes_no'];

$font_yes_no = $_POST['font_yes_no'];

$fontchoice = $_POST['fontchoice'];

$bannerchoice = $_POST['bannerchoice'];

$navchoice = $_POST['navchoice'];

$colorchoice = $_POST['colorchoice'];

$templatechoice = $_POST['templatechoice'];

$gallerychoice = $_POST['gallerychoice'];

        $homewrite = $_POST['homewrite'];

$aboutwrite = $_POST['aboutwrite'];

 

DEFINE ('DB_USER', 'dbusername'); // Insert your database username into the quotes.

DEFINE ('DB_PASSWORD', 'dbpassword'); // Insert your database password into the quotes.

DEFINE ('DB_HOST', 'dbhost'); // This will most likely stay the same.

DEFINE ('DB_NAME', 'dbname'); //Insert your actual database name in the quotes.

$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not connect to MySQL: ' . mysql_error()); //@ is to o not show errors on the page

@mysql_select_db (DB_NAME) OR die('Could not select the database: ' . mysql_error() );

 

 

$query="INSERT INTO form_data (fname, lname, cname, address, phone, email, logo_yes_no, font_yes_no, fontchoice, bannerchoice, navchoice, colorchoice, templatechoice, gallerychoice, homewrite, aboutwrite) VALUES ('$fname', '$lname', '$cname', '$address', '$phone', '$email', '$logo_yes_no', '$font_yes_no', '$fontchoice', '$bannerchoice', '$navchoice', '$colorchoice', '$templatechoice', '$gallerychoice', '$homewrite', '$aboutwrite')"; //form_data is the name of the MySQL table where the form data will be saved.

 

$numR = mysql_num_rows($sql);

 

echo "Database updated with: $fname ";

 

 

?>

 

I'm sending the variables from Flash though and the php link is correct, here's the flash code so far:

 

//Send and Load variables

var form_process:LoadVars = new LoadVars();

 

      send_btn.onRelease = function() {

          var post_variable:LoadVars = new LoadVars();

          post_variable.fname = fname_txt.text;

  post_variable.lname = lname_txt.text;

  post_variable.cname = cname_txt.text;

  post_variable.address = address_txt.text;

  post_variable.phone = phone_txt.text;

  post_variable.email = email_txt.text;

  post_variable.logo_yes_no = logo_yes_no;

  post_variable.font_yes_no = font_yes_no;

  post_variable.fontchoice = fontchoice;

  post_variable.bannerchoice = bannerchoice;

  post_variable.navchoice = navchoice;

  post_variable.colorchoice = colorchoice;

  post_variable.templatechoice = templatechoice;

  post_variable.gallerychoice = gallerychoice;

  post_variable.homewrite = homewrite_txt.text;

  post_variable.aboutwrite = aboutwrite_txt.text;

          post_variable.sendAndLoad("http://www.mediagord.com/yellowday/form/form.php",form_process,"POST");

      };

 

 

 

      form_process.onLoad = function(success:Boolean) {

          if (success) {

              trace("Neeeee Haaaaawwwwwwwww!!!!!!!");

          }

          else {

              results_txt.text = "Error connecting to server.";

          }

      };

Most immediate thing I see is that you are not actually sending the query to the database.  All you are doing is assigning your query string to a variable. You need to send it to the db with something like mysql_query.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.