无法让php发布到mysql

Hello I cannot get my php to post to mysql. I get no errors when submitting, but entries are not showing up in my database. I appreciate anyone that can give me advice on how I can fix this. I tried to search around here but couldnt find a dirrect reason on why my php code is not working.

<?php
if (isset($_POST['submit'])) {

if (empty($_POST['element_1']) || empty($_POST['element_2'])) {
    die("You have forgotten to fill in one of the required fields! Please make sure you submit your name, and paypal e-mail address");
}

$entry = htmlspecialchars(strip_tags($_POST['entry']));
$timestamp = htmlspecialchars(strip_tags($_POST['timestamp']));
$name = htmlspecialchars(strip_tags($_POST['element_2']));
$email = htmlspecialchars(strip_tags($_POST['element_1']));
$comment = htmlspecialchars(strip_tags($_POST['element_3']));
$comment = nl2br($comment);

if (!get_magic_quotes_gpc()) {
    $name = addslashes($name);
    $url = addslashes($url);
    $comment = addslashes($comment);
}

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
     die("The e-mail address you submitted does not appear to be valid. Please go back and correct it.");
}

mysql_connect('host', 'username', 'password') ;
mysql_select_db('database name');

$result = mysql_query("INSERT INTO payments (entry, timestamp, name, email, comment) VALUES ('$entry','$timestamp','$name','$email','$comment')");

header("Location: post.php?id=" . $entry);
}
else {
die("Error: you cannot access this page directly.");
}
?>

Thanks in advanced for your time, understanding, and knowledge. I greatly appreciate it.

advice on how I can fix this

  1. use var_dump($_POST); after if(isset($_POST['submit']))
  2. do $sql="" and var_dump($sql) and mysql_query($sql);
  3. after query var_dump(mysql_insert_id());
  4. and var_dump(mysql_error()); and dont forget: error_reporting(E_ALL); at the top of the file Then look what happens

[optional] after first query use SHOW COUNT(*) WARNINGS

Things you should check:

  1. I cant see your database design, so you'll have to make sure that your database columns and table match correctly with what is specified in your database.
  2. echo your variables to make sure none are empty.
  3. Ensure that you are not inserting a string in column of type int or vice versa.
  4. Make sure your form method is POST and that your name attributes match what you have specified in your variables ie $_POST['name_attr'].
  5. The order of your insert columns should be the same order as in your table.
  6. Lastly, i hope host,username,password and database name are just placeholders for your real database info? if not, that's the problem.