當我嘗試使用 PHP 更新 SQL Server 中的數(shù)據(jù)時出現(xiàn)錯誤。這是PHP代碼:$sql = "UPDATE Warehouse SET Items = CAST( ? AS varbinary(1920)) WHERE AccountID = 'shono'";$params = array($vip_cat);$stmt = sqlsrv_query( $conn_ms, $sql, $params);if( $stmt === false ) { die( print_r( sqlsrv_errors(), true));}else{ echo 'ok';}這是我的錯誤:無效值的一個示例是標度大于精度的數(shù)字類型數(shù)據(jù)。) )我嘗試了什么:$sql = "UPDATE Warehouse SET Items = CAST( (?) AS varbinary(1920)) WHERE AccountID = 'shono'";和:$sql = "UPDATE Warehouse SET Items = CAST( $vip_cat AS varbinary(1920)),WarNum = (?) WHERE AccountID = 'shono'";$params = array(1);
1 回答

侃侃爾雅
TA貢獻1801條經(jīng)驗 獲得超16個贊
這是問題所在
$sql = "UPDATE Warehouse SET Items = CAST( **?** AS varbinary(1920)) WHERE AccountID = 'shono'";
**$params = array($vip_cat);**
$stmt = sqlsrv_query( $conn_ms, $sql, **$params**);
我們只需要從 $stmt = sqlsrv_query( $conn_ms, $sql, $params );中刪除 $params 我們會得到這樣的正確代碼
$stmt = sqlsrv_query( $conn_ms, $sql);
此外,這里將是 SQL 的正確命令
UPDATE Warehouse SET Items = CAST(
0x00..
AS varbinary(1920)) WHERE AccountID = 'shono'
- 1 回答
- 0 關(guān)注
- 114 瀏覽
添加回答
舉報
0/150
提交
取消