PHP MSSQL试图将二进制文件传递到存储过程-无法绑定

PHP MSSQL试图将二进制文件传递到存储过程-无法绑定,php,sql-server,stored-procedures,binary-data,Php,Sql Server,Stored Procedures,Binary Data,谷歌在这方面帮不了什么忙。我试图使用存储过程将一个二进制文件从PHP推入SQL Server数据库。问题是,当我尝试绑定文件时,PHP会抛出一个错误: Warning: mssql_bind() [function.mssql-bind]: Unable to set parameter in C:\inetpub\wwwroot\squidersbeta\squidersbeta6\cv_submit_send.php on line 36 Warning: mssql_execute() [

谷歌在这方面帮不了什么忙。我试图使用存储过程将一个二进制文件从PHP推入SQL Server数据库。问题是,当我尝试绑定文件时,PHP会抛出一个错误:

Warning: mssql_bind() [function.mssql-bind]: Unable to set parameter in C:\inetpub\wwwroot\squidersbeta\squidersbeta6\cv_submit_send.php on line 36
Warning: mssql_execute() [function.mssql-execute]: message: Procedure or function 'UploadCV' expects parameter '@fileData', which was not supplied. (severity 16) in C:\inetpub\wwwroot\squidersbeta\squidersbeta6\cv_submit_send.php on line 39  
我在Windows2008x64上使用PHP5.2,使用MSSQL驱动程序。如果可能的话,我希望继续使用它们,因为SQLSRV驱动程序对我来说似乎不能正常工作。我发现我必须将数据作为VARCHAR推入,因此我的脚本将文件作为字符串读入,然后将其传递给SP。代码片段调用:

$fileBinary = bin2hex(file_get_contents($_FILES['cv_file']['tmp_name']));
//Prepare to execute the Stored Procedure
$spCall = mssql_init("UploadCV", $DBhandle);
--SNIP--
mssql_bind($spCall,"@fileData",$fileBinary, SQLVARCHAR, false, false, -1); //This is the line that breaks
mssql_bind($spCall, "@fileName", $_FILES['cv_file']['name'], SQLVARCHAR);
mssql_bind($spCall, "@fileType", $_FILES['cv_file']['type'], SQLVARCHAR);
mssql_execute($spCall) or die("Uh-oh, query failed!".mssql_get_last_message());

我尝试了bind()调用的各种变体,包括指定的$maxlength和未指定的$maxlength。我看到有人提到SQLVARCHARs可能限制为254个字符——这是真的吗?有什么办法可以解决吗?谢谢。

根据我的经验,mssql_bind限制为255个字符,我通过
@inputParam01、@inputParam02、@inputParam03、@inputParam04…
等和/或循环过程调用来“绕过”它,这真是糟糕透顶。你做你必须做的事。也许当官方的microsoft PHP驱动程序支持表变量参数时,我们会有足够的动力切换。@KM感谢您的提示;我真的很讨厌从PHP(见鬼,从任何语言)访问MSSQL,我想我只是要将数据库转换成MySQL并使用它。干杯