无法使用php将数据插入到mysql中的表中

时间:2022-09-25 21:32:11

here, i try to insert some data from my form, but there is always not inserted and i dont know where is the error, hope anyone tell me :)

在这里,我尝试从我的表单插入一些数据,但总是没有插入,我不知道错误在哪里,希望有人告诉我:)

my insert code

我的插入代码

$sql="INSERT INTO $tbl_name (buyername, buyerjob, buyercompany, buyeraddress, buyercity, buyerpost, buyerphone, buyerfax, buyeremail, buyerweb, buyernob, buyertoo, buyerhonor)
`VALUES ('$name', '$job', '$company', '$address', '$city', '$post', '$phone', '$fax', '$email', '$web', '$nob', '$too', '$bhonor')";

is there any error? hope anyone help

有什么错误吗?希望有人帮忙

Error Message

#1452 - Cannot add or update a child row: a foreign key constraint fails 
(reg_db.buyer_db, CONSTRAINT buyer_db_ibfk_1 FOREIGN KEY (spouse_id) REFERENCES 
spouse_db (spouse_id))

1 个解决方案

#1


0  

You don't set a value of spouse_id field, but error message says that it is mandatory and must be set to a value present in spouse_db table.

您没有设置spouse_id字段的值,但错误消息表明它是必需的,必须设置为spouse_db表中的值。

#1


0  

You don't set a value of spouse_id field, but error message says that it is mandatory and must be set to a value present in spouse_db table.

您没有设置spouse_id字段的值,但错误消息表明它是必需的,必须设置为spouse_db表中的值。