macers Posted July 18, 2010 Share Posted July 18, 2010 I am unable to get the user form data to insert into my mysql database. I have the action="thankyou.php" and have placed the following php code top that page.... <?php require_once( 'nipadmin/config.php' ); require_once( 'nipadmin/utils.php' ); session_start(); define('DB_HOST', 'db_host'); define('DB_USER', 'db_user'); define('DB_PASS', 'db_pass'); define('DB_NAME', 'db_name'); if ($dbConn = mysql_connect(DB_HOST, DB_USER, DB_PASS)) { if (mysql_select_db(DB_NAME, $dbConn)) { $firstName = mysql_real_escape_string($_POST['firstname']); $lastName = mysql_real_escape_string($_POST['lastname']); $phone = mysql_real_escape_string($_POST['phone']); $state = mysql_real_escape_string($_POST['state']); $event = mysql_real_escape_string($_POST['event']); $siteCode = mysql_real_escape_string($_POST['scode']); $ipAddress = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); $dbQuery = mysql_query("INSERT INTO user_signup (event_id, firstname, lastname, email, phone, state, sitecode, ip_address, date) VALUES (".$event.", '".$fistName."', '".$lastName."', '".$email."', '".$phone."', '".$state."', '".$siteCode.", '".$ipAddress."', ".time().")", $dbConn); if (!$dbQuery) { print '<!-- MySQL Error: '.mysql_error().' -->'; } } else { print '<!-- MySQL Error: '.mysql_error().' -->'; } } else { print '<!-- MySQL Error: '.mysql_error().' -->'; } ?> Can somebody let me know what is keeping my script from submitting the form data input by the user...I've been stumped for sometime now...need help. thanks in advance! If this is of any help here is the site with the form....www.newinvestorpreview.com Collin Quote Link to comment https://forums.phpfreaks.com/topic/208076-form-submission-code-for-thankyouphp-page-to-insert-form-data-into-user-table/ Share on other sites More sharing options...
Pikachu2000 Posted July 18, 2010 Share Posted July 18, 2010 Why are all of the mysql_error()s in html comment tags? Have you viewed the page source to see if there are any errors showing in it? I'd suggest echoing your query string out to make sure it contains the values you'd expect it to contain also. Quote Link to comment https://forums.phpfreaks.com/topic/208076-form-submission-code-for-thankyouphp-page-to-insert-form-data-into-user-table/#findComment-1087666 Share on other sites More sharing options...
macers Posted July 18, 2010 Author Share Posted July 18, 2010 MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '209.189.246.194', 1279429203)' at line 3 Any idea what that 209 and 127 number means? I deleted the html comment code...thanks. Quote Link to comment https://forums.phpfreaks.com/topic/208076-form-submission-code-for-thankyouphp-page-to-insert-form-data-into-user-table/#findComment-1087675 Share on other sites More sharing options...
jcbones Posted July 18, 2010 Share Posted July 18, 2010 '".$siteCode." <- MISSING a single quote('); Full Line: $dbQuery = mysql_query("INSERT INTO user_signup(event_id, firstname, lastname, email, phone, state, sitecode, ip_address, date) VALUES (".$event.", '".$fistName."', '".$lastName."', '".$email."', '".$phone."', '".$state."', '".$siteCode."', '".$ipAddress."', ".time().")", $dbConn); Quote Link to comment https://forums.phpfreaks.com/topic/208076-form-submission-code-for-thankyouphp-page-to-insert-form-data-into-user-table/#findComment-1087677 Share on other sites More sharing options...
macers Posted July 18, 2010 Author Share Posted July 18, 2010 Thanks so much! That missing quote was the answer I was looking for...I appreciate it greatly. Collin Quote Link to comment https://forums.phpfreaks.com/topic/208076-form-submission-code-for-thankyouphp-page-to-insert-form-data-into-user-table/#findComment-1087681 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.