lt40 Posted June 13, 2008 Share Posted June 13, 2008 hi, Could you tell me what is wrong with this code. after the post data is submitted nothing changed in phpmyadmin. Note: some of the post data will be blank will this still work? <?php include 'includes/header.inc'; include 'includes/config.php'; // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); mysql_query("INSERT INTO contact (app_code, name, sub, contact, what, email) VALUES ('" . $_POST['app'] . "','" . $_POST['name'] . "','" . $_POST['subject'] . "','" . $_POST['contact'] . "','" . $_POST['info'] . "','" . $_POST['email'] . "')"); include 'includes/footer.inc'; ?> Thanks Quote Link to comment Share on other sites More sharing options...
bravo81 Posted June 13, 2008 Share Posted June 13, 2008 Hi there, Try insterting: if (mysql_affected_rows() != 1) die ('Query failed: '.mysql_error()); Onto the line below your INSERT INTO code. This should tell you what is wrong. Quote Link to comment Share on other sites More sharing options...
fenway Posted June 13, 2008 Share Posted June 13, 2008 Even better, post the actual sql query, not the php variable. Quote Link to comment Share on other sites More sharing options...
lt40 Posted June 13, 2008 Author Share Posted June 13, 2008 Thanks for the quick response i used the code. if (mysql_affected_rows() != 1) die ('Query failed: '.mysql_error()); Found the problem Incorrectly named column email was actually labeled e-mail. Now i feel stupid Quote Link to comment Share on other sites More sharing options...
fenway Posted June 13, 2008 Share Posted June 13, 2008 You shouldn't use a minus sign in your column name -- underscores are much better! 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.