首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mysql/php bind_param设置为空

Mysql/php bind_param设置为空
EN

Stack Overflow用户
提问于 2014-11-27 14:24:32
回答 2查看 150关注 0票数 0

它显示“错误:列'DeliveredDate‘不能为null。”

代码语言:javascript
复制
$delivereddate = null;
$stmt = $connection->prepare("INSERT INTO orders (receiptid, date, cid, cardno, expirydate,      expecteddate, delivereddate) VALUES (?,?,?,?,?,?,?)");
$stmt->bind_param("sssssss", $receiptid, $date, $cid, $cardno, $expirydate, $expecteddate, $delivereddate);

相关表格如下:

代码语言:javascript
复制
CREATE TABLE Orders(
ReceiptId char(30) not null,
Date date not null,
CId char(30) not null,
CardNo char(30) not null,
ExpiryDate date not null,
ExpectedDate date not null,
DeliveredDate date, 
PRIMARY KEY(ReceiptId));

我尝试在mysql工作台中插入值,我可以这样做:

代码语言:javascript
复制
INSERT INTO orders VALUE
(1, '2012-12-10', 1, 1, '2014-2-3', '2012-12-23', null);
EN

回答 2

Stack Overflow用户

发布于 2014-11-27 14:35:55

尝尝这个

代码语言:javascript
复制
$delivereddate = '2014-11-26 10:40:35';  // some date
$stmt = $connection->prepare("INSERT INTO orders (receiptid, date, cid, cardno, expirydate,      expecteddate, delivereddate) VALUES (?,?,?,?,?,?,?)");
$stmt->bind_param("sssssss", $receiptid, $date, $cid, $cardno, $expirydate, $expecteddate, $delivereddate);

我认为这个错误是由于$delivereddate = null;造成的

错误注释...

票数 1
EN

Stack Overflow用户

发布于 2014-11-27 14:46:42

只需将表sql更改为允许DeliveryDate列的NULL即可。

代码语言:javascript
复制
CREATE TABLE Orders(
ReceiptId char(30) not null,
Date date not null,
CId char(30) not null,
CardNo char(30) not null,
ExpiryDate date not null,
ExpectedDate date not null,
DeliveredDate date null, 
PRIMARY KEY(ReceiptId));

剩下的应该可以用了。(假设您希望在该列中存储null )

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27164321

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档