Jump to content

[SOLVED] PHP to insert flash form into mySQL


Iron Bridge

Recommended Posts

I have created a flash site for my upcoming wedding.  In the site I have created a form to collect the addresses of guests.  Currently that form is emailed to me via PHP.  I would like to have the contents of that form inserted into a mySQL DB.  The error appears to be in my PHP script. 

 

My PHP and SQL knowledge are quite limited as this is the first SQL DB I have set up.  The database is quite simple and consits of id (auto incremented), name, address, and email.  Below is my latest version of my PHP script.  The only thing changed is my $DBuser, and $DBpass.  I am wondering if the answer is something as simple as having the wrong $DBhost.  Do I need to place the actual IP address? The email portion of the script works fine, which leads me to believe that my problem is with the SQL connection or the INSERT INTO portion of the script.  Maybe it is my sytax. 

Hopefully somebody can help

 

<?
//SQL PORTION OF SCRIPT

// Database Connectivity Variables and other Variables
   $DBhost = "http://mysql299.secureserver.net";   // Database Server
   $DBuser = "myUserName";            // Database User
   $DBpass = "myPassword";            // Database Pass
   $DBName = "febridge";            // Database Name
   $table = "guestList";             // Database Table
   
   // Connect to mySQL Server
   $DBConn = mysql_connect($DBhost,$DBuser,$DBpass);
   // Select mySQL Database
   mysql_select_db($DBName, $DBConn);

// Recieve Variables From Flash
$name = stripslashes($HTTP_POST_VARS['sender_name']);
$email = stripslashes($HTTP_POST_VARS['sender_mail']);
$comments = stripslashes($HTTP_POST_VARS['sender_message']);

	 // Insert the data into the mysql table
$sql = "INSERT INTO guestList (name ,email)  
    	VALUES ('$name','$email')"; 
$insert = mysql_query($sql, $DBConn);


//EMAIL PORTION OF SCRIPT

if(!empty($HTTP_POST_VARS['sender_mail']) || !empty($HTTP_POST_VARS['sender_message']) || !empty($HTTP_POST_VARS['sender_subject']) || !empty($HTTP_POST_VARS['sender_address']) || !empty($HTTP_POST_VARS['sender_name']))
{
$to = "febridge@myEmailAddress";
$subject = "wedding guest address";
$body = stripslashes($HTTP_POST_VARS['sender_message']);
$body .= "\n\n---------------------------\n";
$body .= "Mail sent by: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail']  . ">\n";
$body .= "Our Address is: " . $HTTP_POST_VARS['sender_address'] . "";
$header = "From: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$header .= "Reply-To: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$header .= "X-Mailer: PHP/" . phpversion() . "\n";
$header .= "X-Priority: 1";
if(@mail($to, $subject, $body, $header))
{
	echo "output=sent";
} else {
	echo "output=error";
}
} else {
echo "output=error";
}
?>

Link to comment
Share on other sites

after all the mysql_** functions, add or die(mysql_error());

 

$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die(mysql_error());

mysql_select_db($DBName, $DBConn) or die(mysql_error());

 

etc. (keep doing it on the rest, query, etc) That will show you where it's breaking and why.

Link to comment
Share on other sites

OK so this is what I get back

 

Warning: mysql_connect(): Unknown MySQL Server Host 'http' (0) in /home/content/I/r/o/Ironwebmaster/html/sendmail2.php on line 12

 

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/content/I/r/o/Ironwebmaster/html/sendmail2.php on line 14

 

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/content/I/r/o/Ironwebmaster/html/sendmail2.php on line 39

output=error

 

I am assuming this all means that I am having a mysql_connect problem.  Do I have the DBhost wrong?  Do I need the actual IP address (I don't think so)? 

 

I appreciate the help thus far.  At least I can now trace as I do in flash.

Link to comment
Share on other sites

It is on goDaddy.  I had just tried that before checking back.  The response I got was:

 

No input file specified.

 

I assumed that this meant it was connecting correctly.  So, I went to my form and inputted some data and.......

 

It worked.  Thank you so much.  Sometimes, it just helps to communicate with someone (even if it is via forum).  I can't tell you how much this will help me.  I really appreciate it, you are AWESOME!

 

 

Link to comment
Share on other sites

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.