$query = "INSERT INTO api_fails SET file=?, code=?, url=?, date=".time().")";
$stmt = $mysqli->stmt_init();
if(!$stmt->prepare($query)) {
echo("Failed to prepare statement.<br />\n");
} else {
$file = (isset($_GET['f'])) ? $_GET['f'] : '' ;
$code = (isset($_GET['c'])) ? $_GET['c'] : '' ;
$url = (isset($_GET['u'])) ? $_GET['u'] : '' ;
$stmt->bind_param("sis", $file, $code, $url);
if($stmt->execute()) {
echo("Inserted.<br />\n");
}else {
echo("Didn't insert.<br />\n");
}
}
我得到以下输出:
Failed to prepare statement.
答案 0 :(得分:0)
尝试
$query = "INSERT INTO api_fails SET file=?, code=?, url=?, date=?)"; $stmt = $mysqli->stmt_init(); if(!$stmt->prepare($query)) { echo("Failed to prepare statement.
\n"); } else { $file = (isset($_GET['f'])) ? $_GET['f'] : '' ; $code = (isset($_GET['c'])) ? $_GET['c'] : '' ; $url = (isset($_GET['u'])) ? $_GET['u'] : '' ; $time = time(); $stmt->bind_param("sisi", $file, $code, $url,$time); if($stmt->execute()) { echo("Inserted.
\n"); }else { echo("Didn't insert.
\n"); } }
答案 1 :(得分:0)
根据您的工作查询,我会说您的错误在日期值附近缺少引号:
$query = "INSERT INTO api_fails SET file=?, code=?, url=?, date='".time()."')";