When I run this there are no errors thrown but also no data gets stored. I have confirmed that the connection is working (I can select rows from tables).
$host = 'localhost';
$db = 'property';
$user = 'root';
$pass = '1234';
$charset = 'utf8';
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
];
$pdo = new PDO($dsn, $user, $pass, $opt);
$stmt = $pdo->prepare("INSERT INTO Properties (AccountNumber, LegalDescription, PhysicalAddress, SaleStatus) VALUES (:AccountNumber, :LegalDescription, :PhysicalAddress, :SaleStatus)");
$stmt->bindParam(':AccountNumber', '1234');
$stmt->bindParam(':LegalDescription', 'BLOCK 6 LOT 7');
$stmt->bindParam(':PhysicalAddress', '0 FOURTH AVE');
$stmt->bindParam(':SaleStatus', 'PENDING');
if ($stmt->execute()) {
echo 'Success!<br />';
} else {
echo $stmt->error;
}
What other logging can I add to figure out why this is failing? I have scattered line number echo statements throughout to see where the process stops and as far as I can tell, it does not get past the line "$stmt = $pdo->prepare"...never makes it as far as the first bindParam line.
Aucun commentaire:
Enregistrer un commentaire