我已经检查了几天,我只是找不到它出错的原因。我没有收到 php 警告,只是错误处理程序“出现错误”而不是插入。我知道这里的优秀年轻小伙子可能会在几秒钟内发现它,尤其是考虑到它只是一个简单的插入语句,但我被搞砸了。提前致谢。
include('core.inc.php');
$sql = 'INSERT INTO $resultsTable (
id,
firstName,
lastName,
email,
birthday,
anniversary,
location,
campaign
)
VALUES (NULL,?,?,?,?,?,?,?)';
$stmt = $mysql->stmt_init();
if ($stmt->prepare($sql)) {
// bind parameters and execute statement
$stmt->bind_param(
'sssssss',
$_POST['fname'],
$_POST['lname'],
$_POST['email'],
$_POST['birthday'],
$_POST['anniversary'],
$_POST['location'],
$campaign
);
$OK = $stmt->execute();}
// return if successful or display error
if ($OK) {$response = "Success";}
else {$response ="Something went wrong.";}
}