1

我花了超过 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);
    }

}
4

2 回答 2

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);


}

}
于 2016-07-07T07:57:49.403 回答
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);
    }
}
于 2016-07-07T08:12:59.537 回答