PDO Insert fails, direct substitution succeeds
Posted by:
Brian Case
Date: August 22, 2018 08:45AM
This code fails but does not throw an exception
***
$sql = "INSERT INTO payment(
projectid,
checknumber,
checkamount,
checkdate ) VALUES (
:projectid,
:checknumber,
:checkamount,
:checkdate
)";
$stmt = $this->conn->prepare($sql);
$stmt->bindParam(':projectid', $_SESSION['payment'], PDO::PARAM_INT);
$stmt->bindParam(':checknumber', $payment['checknumber'], PDO::PARAM_STR);
$stmt->bindParam(':checkamount', $payment['checkamount'], PDO::PARAM_STR);
$stmt->bindParam(':checkdate', $payment['checkdate'], PDO::PARAM_INT);
try {
$stmt->execute();
...
***
But when I simply replace the variables, it posts to the database properly
***
$sql = "INSERT INTO payment(
projectid,
checknumber,
checkamount,
checkdate ) VALUES (
9,
'1004',
6335.96,
1512342000
)";
try {
$stmt->execute();
...
***