sqlsrv_query , php 传入的表格数据流 (TDS) 远程过程调用 (RPC) 协议流不正确

sqlsrv_query , php The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect

当我尝试使用 PHP 更新 SQL 服务器中的数据时出现错误。

这里是 PHP 代码:

$vip_cat = 0x067F63DDED21007F0070000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF067F63E35D57007F0080000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF067F63CFA8BE007F0090000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF067F63B93289007F00A0000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF067F63FF0228007F00B0000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF057FFF05CE4B007F00C0000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF14FF959056E2007F000000000000000014FF958DA41D007F0000000000000000157B6D3D506C007F00D0000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF157B6D20EFEA007F00D00000000000005078FF60F6B4000000D00000000000004178FF15D6A7000000D0000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0D7B6DA77805007F00D00000000000004078FFBC44CE000000D00000000000000B60009C2B59000000E00000000000000B6000CB7DB8000000E00000000000000B60007AB69B000000E00000000000000B60001117F2000000E0000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0B60009C1DED000000E0000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF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FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;

$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';
}

这是我的错误:

Array ( [0] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 8023 [code] => 8023 [2] => [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 3 (""): The supplied value is not a valid instance of data type float. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision. [message] => [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 3 (""): The supplied value is not a valid instance of data type float. Check the source data for invalid values. An example of an invalid value is data of numeric type with scale greater than precision. ) )

我尝试了什么:

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

问题来了

$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'