MySQL Forums
Forum List  »  PHP

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();
...
***

Options: ReplyQuote


Subject
Written By
Posted
PDO Insert fails, direct substitution succeeds
August 22, 2018 08:45AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.