gpt4 book ai didi

php - 向外键插入数据时出错

转载 作者:行者123 更新时间:2023-11-29 10:36:30 25 4
gpt4 key购买 nike

有人可以帮助我吗,我已经被这个问题困扰了很长一段时间,而且对此也很陌生。我有一个表(tbl_call_log_detail),其中包含2个外键(dealer_id引用tbl_dealer_info中的id和type_of_call引用tbl_call_types中的id)。我正在尝试更新我的表单,它可以正常工作。然后我希望更新中的相关字段自动插入到 tbl_call_log_detail 中。这就是我失去理智的原因

$query = "SELECT id FROM tbl_dealer_info WHERE account_name = '$account_name' INTO $dealer_id";
$result = mysqli_query($conn, $query);
$query2 = "SELECT id FROM tbl_call_types WHERE type_of_call = '$type_of_call' INTO $type_of_call";
$result2 = mysqli_query($conn, $query2);

$sql = "INSERT INTO tbl_call_log_detail ";
$sql .= "(comment, time_stamp, type_of_call, dealer_id) ";
$sql .= "VALUES ";
$sql .= "('$_POST[comments]', '$_POST[time_stamp]', '$type_of_call', '$dealer_id') ";
mysqli_query($conn, $sql);
}

当我回显插入语句然后将其复制粘贴到 phpmyadmin 时,出现错误

'Incorrect integer value: change in region' for column 'type_of_call'

最佳答案

'Incorrect integer value: change in region' for column 'type_of_call

此处type_of_call位于整数列中,并且您尝试插入'change in region',一个字符串 其中的值(value)。

关于php - 向外键插入数据时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46324861/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com