>  기사  >  백엔드 개발  >  insert-php+mysql中插入语句,时间前面为什么要有空格

insert-php+mysql中插入语句,时间前面为什么要有空格

WBOY
WBOY원래의
2016-06-02 11:32:221011검색

insertphpmysqli

数据表如下:

#
Name
Type
Collation
Attributes
Null
Default
Extra
Action

1
id
int(10)

UNSIGNED
No
None
AUTO_INCREMENT
Change
Drop
More

2
author
char(20)
utf8_general_ci

No
None

Change
Drop
More

3
addtime
datetime

No
None

Change
Drop
More

4
content
varchar(100)
utf8_general_ci

No
None

Change
Drop
More

5
reply
varchar(100)
utf8_general_ci

No
None

Change
Drop
More
Check AllWith selected: Browse Change Drop Primary Unique Index

Print view Relation view Propose table structure Move columns

Add column(s) At End of Table At Beginning of Table Afteridauthor addtimecontentreply

  • IndexesInformationSpace usageData16KiBIndex0BTotal16KiBRow statisticsFormatCompactCollationutf8_general_ciNext autoindex2CreationApr 18, 2015 at 10:51 AM

1.只写入时间。
$sql = "INSERT INTO message(addtime,) VALUES ('2015-04-22 08:33:46')";
可以写入,结果如下:

id
主键,自动增长
author
作者
addtime
留言时间
content
留言内容
reply
回复

Edit
Copy
Delete
1

2015-04-22 08:33:46

2.按照表单填写留言。
$sql="INSERT INTO message(author, addtime, content) VALUES ('$name','$addtime','$content')";
可以正常写入,让我困惑的是addtime中的addtime前面为什么必须要有空格?

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.