Hi all. Can anyone see a problem with this simple script? It's not inserting,
and the final try catch block is not throwing. But a "or die()" on the
$stmt->execute line will fire.
try {
$dbh = new PDO("mysql:host=localhost;dbname=glasscorp","user","password");
}
catch (PDOException $e) {
echo $e->getMessage();
}
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, TRUE);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);
// If the form has been submitted - add the user to the system
if(isset($_POST['action']) && $_POST['action'] == 'add') {
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
$email = $_POST['email'];
$company = $_POST['company'];
$date_registered = date("Y-m-d H:i:s");
$password = md5($_POST['auto_password']);
// Insert record, setting flag if success
try {
$stmt = $dbh->prepare("INSERT INTO certs_users
(firstname,surname,company,email,password,date_registered) VALUES (:firstname,
:surname, :company, :email, :password, :date_registered )");
$stmt->bindParam(':firstname', $firstname);
$stmt->bindParam(':surname', $surname);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':company', $company);
$stmt->bindParam(':password', $password);
$stmt->bindParam(':date_registered', $date_registered);
$stmt->execute();
}
catch (PDOException $e) {
print $e->getMessage();
}
Cheers
Aaron
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---