我花了超过24小时尝试在选择查询后运行更新或插入查询但是选择查询完成并更新或插入查询从未在子网站时执行" displayid"
码##
if($_POST["displayid"]==TRUE) {
$sqlid = "SELECT * FROM doc1 WHERE idnum ='$pidnum' AND stats='$ok'";
$result = mysqli_query($conn, $sqlid);
if (mysqli_num_rows($result) > 0) {
$sqlup = "UPDATE doc1 SET m_phone='$pmphone', seen='$dataseen' WHERE idnum ='$pidnum'";
mysqli_query($conn, $sqlup);
$found=1;
}
else {
$found=0;
$sqlfail="INSERT INTO fail(fname,lname,tname,funame,idnum,m_phone,reg_date) VALUES('$pfname','$plname','$ptname','$pfuname','$pidnum','$pm_phone','$todaydate')";
$conn->query($sqlfail);
}
}
答案 0 :(得分:0)
$ conn对象来自哪里?试试这个..
<?php
if($_POST["displayid"])
{
$sqlid = "SELECT * FROM doc1 WHERE idnum ='$pidnum' AND stats='$ok'";
$result = mysqli_query($conn, $sqlid);
if (mysqli_num_rows($result) > 0)
{
$sqlup= "UPDATE doc1 SET m_phone='$pm_phone' AND seen='$dataseen' WHERE idnum ='$pidnum'";
mysqli_query($conn, $sqlup);
$found=1;
}
else
{
$found=0;
$sqlfail="INSERT INTO fail(fname,lname,tname,funame,idnum,m_phone,reg_date)
VALUES('$pfname','$plname','$ptname','$pfuname','$pidnum','$pm_phone','$todaydate')";
mysqli_query($conn, $sqlfail);
}
}
答案 1 :(得分:0)
首先你更新查询是错误的。 检查错误请添加
error_reporting(E_ALL);
ini_set('display_errors', 1);
更新了代码
if ($_POST["displayid"] == TRUE) {
$sqlid = "SELECT * FROM doc1 WHERE idnum ='$pidnum' AND stats='$ok'";
$result = mysqli_query($conn, $sqlid);
if (mysqli_num_rows($result) > 0) {
$sqlup = "UPDATE doc1 SET m_phone='$pm_phone', seen='$dataseen' WHERE idnum ='$pidnum'";
mysqli_query($conn, $sqlup);
$found = 1;
} else {
$found = 0;
$sqlfail = "INSERT INTO fail(fname,lname,tname,funame,idnum,m_phone,reg_date)
VALUES ('$pfname','$plname','$ptname','$pfuname','$pidnum','$pm_phone','$todaydate')";
$conn->query($sqlfail);
}
}