当我在没有函数的情况下编写代码时,它可以工作,否则我会收到500连接错误。不确定我做了什么错误。这是我的代码:
$date = "2016-01-12";
$date = date("Y-m-d", strtotime($date));
$sql = 'INSERT INTO `campaigns` (campaign_id, campaign_date) VALUES (9001, "' . $date . '")';
$result = $link->query($sql);
if ($result) {
echo "database updated";
} else {
echo $link->error;
}
function insertIntoDB($mysqli, $date) {
$sql = 'INSERT INTO `campaigns` (campaign_id, campaign_date) VALUES (9001, "' . $date . '")';
$result = $mysqli->query($sql);
if ($result) {
echo "database updated";
} else {
echo $mysqli->error;
}
}
insertIntoDB($link, $date);
答案 0 :(得分:0)
当我在上面定义它时调用它时,该函数正常工作。说不上。