-3

我有一个错误说

在第 189 行调用 C:\xampp\htdocs\initializr\search.php 中非对象的成员函数 mysql_affected_rows()

当我点击我的提交按钮时。

if(isset($_POST['select'])) {
    $studId = $_REQUEST['studid'];

    foreach ($studId as $ch) {
        $result = $mysqli->query("INSERT INTO tbl_tempCand (datetime, names) VALUES (CURRENT_TIMESTAMP(), '".$ch."')");
        //this is my line 189 error
        if($row->mysql_affected_rows($result)==0) {
            header("Location: registercand.php");
        } else {
            echo "nothing happen";
        }
    }
}

这是为什么?

4

1 回答 1

0

使用这个查询

$result = $mysqli->query("INSERT INTO tbl_tempCand (`datetime`, `names`) VALUES (CURRENT_TIMESTAMP(), '".$ch."')");
                                                    ^ // here was the problem

datetime是一个保留字mysql因此查询失败。如果您想使用这种保留字作为列,请在其中引用它们``

改变

if($row->mysql_affected_rows($result)==0)

if($mysqli->affected_rows > 0)
于 2013-02-06T12:03:21.510 回答