Iron Bridge Posted February 7, 2007 Share Posted February 7, 2007 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"; } ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 7, 2007 Share Posted February 7, 2007 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. Quote Link to comment Share on other sites More sharing options...
Iron Bridge Posted February 7, 2007 Author Share Posted February 7, 2007 I originally had those, but as I said I am a total PHP newb. How can I see where it is breaking when my data is coming from flash? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 7, 2007 Share Posted February 7, 2007 Oh sorry. Just go to the file in your browser, so you can see. I have no experience with flash, but you should still be able to view the .php file and check the connections. Quote Link to comment Share on other sites More sharing options...
Iron Bridge Posted February 7, 2007 Author Share Posted February 7, 2007 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. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 7, 2007 Share Posted February 7, 2007 try using mysql299.secureserver.net instead of http://mysql299.secureserver.net Is this on godaddy? Quote Link to comment Share on other sites More sharing options...
Iron Bridge Posted February 7, 2007 Author Share Posted February 7, 2007 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! Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 7, 2007 Share Posted February 7, 2007 No problem Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.