簡體   English   中英

如何在MSSQL中調試資源6錯誤?

[英]How do I debug Resource #6 error in MSSQL?

我有一對單選按鈕,我想以bit的形式將其值插入數據庫。 以下是相同的HTML代碼。

<form  id="Form" method="post" class="overlay"  action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" >
<input type="hidden" id="Keyy" name="key" value="">
<label for="JRadioYes">Active? Yes</label> <input type="radio" id="JRadioYes" name="activeradio"<?php if (isset($ActiveValue) && $ActiveValue == "yes") echo "checked='checked' "; ?>value="yes"> 
        <label for="JRadioNo">No</label> <input type="radio" id="JRadioNo" name="activeradio"<?php if (isset($ActiveValue) && $ActiveValue == "no") echo "checked='checked' "; ?>value="no">
<input type="submit" id="submitter" name="sub" value="Submit!" onclick="decider(this)">
</form>

以下是用於插入數據庫的PHP代碼

// Check if radio is submitted
if (isset ( $_POST ["activeradio"])) 
{
    //Extract values from $_POST and store in variables
    $select_radio = $_POST ["activeradio"];

    if ($select_radio == "yes") {
        $active_status = true;
        //I also tried assigning 1 instead of true
    }
    if ($select_radio == "no") {
        $active_status = false;
        //I also tried assigning 0 instead of false
    }

    if($_POST["key"] == "update")
    {
        try
        {
            echo "<script type='text/javascript'>
                alert('$active_status');
                </script>";
            $JobInt = intval($JobTypeID);
            $stmt = sqlsrv_query ( $conn, 'EXEC spEditThisJobType @Active = ?', array (
                $active_status
            ) );
        }
        catch(Exception $e)
        {
            echo "Error :". $e;
        }
        if($stmt != null)
        {
            echo "<script type='text/javascript'>alert('Successfully Updated!$stmt');
            </script>";
        }
    }
}

我能夠收到顯示“已成功更新”的警報,但同時也出現了資源6錯誤。 而且數據庫不會更新。

我在這里犯了什么錯誤? 請指導我。 先感謝您。

查看sqlsrv_query的文檔-它返回資源對象,而不是查詢結果。

因此,當您回顯"Successfully Updated!$stmt" ,資源$stmt將轉換為其字符串表示形式Resource #6

因此,您要么需要從回顯中刪除$stmt ,要么對資源做一些事情,例如使用sqlsrv_fetch_array讀取數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM