我在hte相同的数据库中有一个表,它与语法或格式没有区别。但是我得到了上面提到的错误?我已经做了我所知道的一切来修复它,但不确定我做错了什么。我也有结构图像。
$sql = "INSERT INTO `FormInfo` (`first_name`,
`last_name`,
`company`,
`address`,
`province`,
`postal`,
`telephone`,
`fax`,
`email`,
`comment`)
VALUES ('$good_data[first_name]',
'$good_data[last_name]',
'$good_data[company]',
'$good_data[address]',
'$good_data[province]',
'$good_data[postal]',
'$good_data[telephone]',
'$good_data[email]',
'$good_data[comment]')";
mysqli_query($cxn, $sql) or die ("Couldn't insert into Database: " . mysqli_error($cxn));
我在这里缺少什么?
答案 0 :(得分:1)
您错过了$good_data[fax]
参数
编辑:另外,请考虑你在阵列中调用对象的方式是不好的做法。有关详细信息,请参阅this
答案 1 :(得分:0)
尝试改变,
$sql = "INSERT INTO `FormInfo` (`first_name`, `last_name`, `company`, `address`, `province`, `postal`, `telephone`, `fax`, `email` ,`comment`) VALUES ('$good_data[first_name]', '$good_data[last_name]', '$good_data[company]', '$good_data[address]', '$good_data[province]', '$good_data[postal]', '$good_data[telephone]', '$good_data[email]', '$good_data[comment]')";
到
$sql = "INSERT INTO `FormInfo` (`first_name`, `last_name`, `company`, `address`, `province`, `postal`, `telephone`, `fax`, `email` ,`comment`) VALUES ('$good_data[first_name]', '$good_data[last_name]', '$good_data[company]', '$good_data[address]', '$good_data[province]', '$good_data[postal]', '$good_data[telephone]', '$good_data[email]', '$good_data[comment]', '$good_data[fax]')";
答案 2 :(得分:0)
您缺少fax
列的插入值:
$SQL = "INSERT INTO `FormInfo`
(`first_name`,
`last_name`,
`company`,
`address`,
`province`,
`postal`,
`telephone`,
`fax`,
`email`,
`comment`
)
VALUES (
'$good_data[first_name]',
'$good_data[last_name]',
'$good_data[company]',
'$good_data[address]',
'$good_data[province]',
'$good_data[postal]',
'$good_data[telephone]',
'$good_data[fax]',
'$good_data[email]',
'$good_data[comment]'
)";