Results 1 to 4 of 4

Thread: Flash form to MySQL Database

  1. #1

    Flash form to MySQL Database

    Good morning ladies and gents.

    I'm attempting to load the contents for a flash form into a mySQL database I've setup. I'm pretty good with flash, a bit of a mySQL and php newbie but I'm sorting things out quickly. I've got the database, table and feilds setup approriately (i think) and thought the code in my PHP file was good. But no dice. The form contents reach me by email but they don't update in the database table.

    See the code below, part of it was from a flash form, then I modified with some code I found in a forum:

    <?php
    /*----------------------------------------------------------
    Author : www.mkeefedesign.com | Matthew Keefe
    Contact : matt@mkeefedesign.com
    $Id: send_email.php ,v 1.0 Tue Apr 26, 2005 02:20 PM
    ------------------------------------------------------------
    * CODING & DESIGN 2004 mkeefeDESIGN | ALL RIGHTS RESERVED
    ------------------------------------------------------------*/

    $recipients = "sturbaindesigns@gmail.com" . ",";
    $subject = "Skin Survey";

    // Grab the key from Flash to ensure security
    $sendKey = $_POST['key'];

    // Only allow the page to send if Flash is the requester
    if($sendKey == "email") {
    // The following three variables are gathered from Flash
    $name = $_POST['name'];
    $lname = $_POST['lname'];
    $email = $_POST['email'];
    $street = $_POST['street'];
    $province = $_POST['province'];
    $postal = $_POST['postal'];
    $city = $_POST['city'];
    $gender = $_POST['gender'];
    $dob = $_POST['dob'];
    $phone = $_POST['phone'];


    // Grab todays date
    $date = date("F j, Y", time());

    // This block is the actual message that is sent in the email
    $email_info .= "Below is the visitors contact info and message.\n\n";
    $email_info .= "Visitor's Info:\n";
    $email_info .= "-----------------------------------------\n";
    $email_info .= "First Name: " . $name . "\n";
    $email_info .= "Last Name: " . $lname . "\n";
    $email_info .= "Email: " . $email . "\n";
    $email_info .= "Street: " . $street . "\n";
    $email_info .= "Province: " . $province . "\n";
    $email_info .= "Postal Code: " . $postal . "\n";
    $email_info .= "City: " . $city . "\n";
    $email_info .= "Gender: " . $gender . "\n";
    $email_info .= "DOB: " . $dob . "\n";
    $email_info .= "Phone: " . $phone . "\n";

    $email_info .= "Date Sent: " . $date . "\n\n";
    $email_info .= "-----------------------------------------\n";

    $mailheaders = "From: <sturbaindesigns@gmail.com> \n";
    $mailheaders .= "Reply-To: " . $email . "\n\n";

    if(mail($recipients, $subject, $email_info, $mailheaders)) {
    print "&success=true";
    mysql_connect("server", "username", "password");
    mysql_select_db("database");
    mysql_query("INSERT INTO table_name (`name`,`lname`,`email`,`street`,`province`,`posta l`,`city`,`gender`,`dob`,`phone`,) VALUES ('$name','$lname','$email','$street','$province',' $postal','$city','$gender','$dob','$phone',)");

    }
    }

    ?>



    Any ideas what I'm doing wrong?

  2. #2
    jwilliam's Avatar
    476
    posts
    An intellectual carrot!
    It looks like your query is malformed. You've got commas at then end of your column list and values list, which is incorrect. Try using mysql_error() to help troubleshoot your queries when they are not working. Also... fyi... it's much easier to read the code if you put it between [PHP] tags.

  3. #3

    thanks!

    Quote Originally Posted by jwilliam View Post
    It looks like your query is malformed. You've got commas at then end of your column list and values list, which is incorrect. Try using mysql_error() to help troubleshoot your queries when they are not working. Also... fyi... it's much easier to read the code if you put it between [php] tags.
    Good direction! Thats jwilliam. One question, how do I use mysql_error() ?

    I'm new with PHP. Still learning.

  4. #4
    44
    posts
    Registered User
    To my understanding, just "dot" mysql_error() anywhere after an "echo" or "print" or use a "die" function and if there are indeed errors, PHP will generate a statement telling you which line in your code is having some problem.

    Like this:
    PHP Code:
    echo "Reason of failure: ".mysql_error(); 
    or if you want to check if a query is working:
    PHP Code:
    $result mysql_query($query) or die('Failed: ".mysql_error()); 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012