试图从另一个表中存储 ID 值并且我得到
注意:数组到字符串的转换
在线
$sql2 = "Insert into relations (id, className) values ($result,'$_POST[className]')";
这是我的代码:
$result = mysqli_query($con,"Select objectID from objects where objectName = '$_POST[relations]'");
if($result === FALSE) {
die(mysqli_error()); // TODO: better error handling
}
$result = mysqli_fetch_assoc($result);
var_dump($result);
$sql = "Insert into classes (className) values ('$_POST[className]')";
$sql2 = "Insert into relations (id, className) values ($result,'$_POST[className]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
if (!mysqli_query($con,$sql2))
{
die('Error: ' . mysqli_error($con));
}
print_r($_POST)
我的调试输出为:
array(1) { ["objectID"]=> string(1) "2" }
Notice: Array to string conversion in C:\xampp\htdocs\matcher\insertclass.php on line 16
Error: Unknown column 'Array' in 'field list'