我创建了一个表单,这里是insert命令,用于将值插入数据库。执行第一个查询$ query1但不执行第二个查询。所以我得到了“卖家INSERT失败”
<?php
$book_author = mysqli_real_escape_string($con, $_POST['b_author']);;
$book_branch = mysqli_real_escape_string($con, $_POST['b_branch']);
$book_edit = mysqli_real_escape_string($con, $_POST['b_edit']);
$book_name = mysqli_real_escape_string($con, $_POST['b_name']);
$book_price = mysqli_real_escape_string($con, $_POST['b_price']);
$book_pub = mysqli_real_escape_string($con, $_POST['b_pub']);
$book_qty = mysqli_real_escape_string($con, $_POST['b_qty']);
$name = mysqli_real_escape_string($con, $_POST['s_name']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$phNo = mysqli_real_escape_string($con, $_POST['phNo']);
$clg = mysqli_real_escape_string($con, $_POST['college']);
$query1 = "INSERT INTO `book_info`(book_author,book_branch,book_edit,book_name,book_price,book_pub,book_qty) VALUES".
"('$book_author','$book_branch','$book_edit','$book_name','$book_price','$book_pub','$book_qty')";
$query2 = "INSERT INTO `seller_info`(seller_name,seller_email,seller_phno,seller_college) VALUES".
"('$name','$email','$phNo','$clg')";
$result1 = mysqli_query($con, $query1);
$result2 = mysqli_query($con, $query2);
if (!$result1)
echo "Book INSERT failed: $query1";
if (!$result2)
echo "seller INSERT failed $query2 <br />".
mysql_error() . "<br /><br />";
?>
答案 0 :(得分:1)
在失败的查询之后,或者代替echo "seller INSERT failed $query2 <br />".
echo mysqli_error($con);
这将告诉您错误是什么。 (可能seller_phno
拼写不正确。)
可以找到更多信息here