我有一个带CURRENT_TIMESTAMP属性的日期字段。我试图在数据库中插入日期,但值存储为' 0000-00-00 00:00:00'。
我的代码:
<?php
if (isset($_POST['submit'])) {
$amount = $_POST['amount'];
$sql = "insert into `od_request` (`username`, `amount`, `status`, `date`) values ('$login_session', '$amount', 'Request', 'NOW()')";
$retval = mysql_query($sql);
if($retval) {
$success= "OD Request Sucessfully Sent!";
} else {
$error = "Sorry! Make sure you have entered all the Fields Correctly.";
}
}
?>
答案 0 :(得分:3)
使用此请求:
function execute(err, array){
loop(array, function(err,object){
console.log(object)
//do a certain task when it's finished get into the next object successively.
});
}
function loop(array,callback){
array.forEach(function(object){
callback(null, object);
});
}
function array(callback){
callback(null, [1, 2, 3, 4, 5]);
}
setTimeout(function(){
array(execute);
}, 6000);
您不需要INSERT INTO `od_request` (`username`, `amount`, `status`, `date`) VALUES('$login_session', '$amount', 'Request', NOW())
'
,因为NOW()
答案 1 :(得分:1)
插入日期的语法错误:
使用func addCubeLoop() {
for var i = 0; i <= 0; ++i {
cube = Cube(num: i, importedCube: importedCube1)
cubeArray.append(cube)
theScene.rootNode.addChildNode(cubeArray[i])
}
}
class Cube: SCNNode {
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
init(num: Int, importedCube: SCNNode) {
let _scale: Float = 60
let cube: SCNNode = importedCube.copy() as! SCNNode
super.init()
cube.scale = SCNVector3Make(_scale, _scale, _scale)
let node = SCNNode()
node.addChildNode(cube)
node.position = SCNVector3Make(5, 20, 3)
let collisionBox = SCNBox(width: 5.0, height: 5.0, length: 5.0, chamferRadius: 0)
node.physicsBody?.physicsShape = SCNPhysicsShape(geometry: collisionBox, options: nil)
node.physicsBody = SCNPhysicsBody.dynamicBody()
node.physicsBody?.mass = 0.1
node.physicsBody?.restitution = 0.8
node.physicsBody?.damping = 0.5
node.name = "dice" + String(num)
node.physicsBody?.allowsResting = true
}
}
而不是NOW()
'NOW()'
答案 2 :(得分:0)
date("Y-m-d H:i:s")
是MySQL日期时间格式
例如
$sql = "insert into `od_request` (`username`, `amount`, `status`, `date`) values ('$login_session', '$amount', 'Request', '".date("Y-m-d H:i:s")."')"
答案 3 :(得分:0)
这是怎么回事?
$sql = "insert into 'od_request' ('username', 'amount', 'status', 'date') values ('$login_session', '$amount', 'Request', NOW())"