This problem is driving me crazy, i tried everything. Is does not give me any error, but it does not insert anything to the database either. Database connection is good, and there should be no typos. Please take a look, and see if you can find the problem:
$err = array();
if (isset($_POST['submit'])) {
$ip = gethostbyname($_SERVER['REMOTE_ADDR']);
$date = "2012-02-02 02:02:02"; //Example
$uploader_name = $_POST['uploader_name'];
// Validation happens here...
if (empty($err)) {
$host = "host";
$dbname = "db";
$user = "user";
$pass = "pass";
try {
$dbh = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$sql = "INSERT INTO `table` (`ip`, `date`, `uploader_name`)
VALUES (:ip, :date, :uploader_name)";
$stmt = $dbh->prepare($sql);
# the data we want to insert
$params = array(
':ip' => $ip,
':date' => $date,
':uploader_name' => $uploader_name
);
$stmt->execute($params);
$dbh = null;
} catch(PDOException $pe) {
die('SQL Error');
}
if (empty($err)) {
$err[] = "Success!";
}
}
}
Also, Im sure it gets to the insert part, because i get the 'Success' message.