【发布时间】:2017-05-30 05:29:43
【问题描述】:
try {
print_r($con->_con);
$save_transaction1 = $con->_con->prepare("INSERT INTO hpay "
. "(amt,entryby,orno,chrgcode) VALUES "
. "(:amt,:entryby,:orno,:chrgcode)");
$save_transaction1->bindValue(":amt", $tenderedamount, PDO::PARAM_STR);
$save_transaction1->bindValue(":entryby", $_SESSION['account_id'], PDO::PARAM_STR);
$save_transaction1->bindValue(":orno", $ornumber, PDO::PARAM_STR);
$save_transaction1->bindValue(":chrgcode", $chargecode, PDO::PARAM_STR);
if ($save_transaction1->execute()) {
echo "asd";
} else {
print_r($con->_con->errorInfo());
}
} catch (PDOException $e) {
echo $e;
}
我有这个在我的数据库中插入数据。但我得到的不是我期望的它没有插入数据库,我得到的 print_r() 是
更新错误
PDO 对象 ( ) 数组 ( [0] => 00000 [1] => 0 [2] => ((null)[0] at (null):0) [3] => )
【问题讨论】:
-
什么是 $dbh 和 $con?
-
@Exprator 抱歉,我没有从我在 SO 中找到的示例中更改它并发布了错误
-
@Exprator 错误是什么意思?我不明白错误
-
这个错误意味着你在 bindvalue 中传递的变量是空白的,尝试打印并检查其中是否有值