0

I am trying to call a MS SQL SP from a php script. When I tried calling the procedure which required an parameter as input (hardcoded the parameter for now ), it failed. The code is below:

$link = mssql_connect('xx.xx.xx.xx', 'xx', 'xx');
$report_id=79;
$proc=mssql_init ('usp_IVR_FormatImportData', $link );
mssql_bind ($proc, '@ReportID', $report_id, SQLINT4, FALSE); 
mssql_execute ($stmt);

The error I got is this:

PHP Warning:  mssql_execute (): message: Conversion failed when converting the varchar value ':2' to data type int. (severity 16) in /var/lib/asterisk/wbrivr/scripts/test.php on line 24

PHP Warning:  mssql_execute(): stored procedure execution failed in /var/lib/asterisk/wbrivr/scripts/mobin3.php on line 24

The same code works fine when I need to call an SP with no input parameters so I am wondering if it is a parameter mismatch or something as indicated by the error line. I am running php 5.1.6 and the server is SQL Server 2008.

Running just this line of code below also gives the same error.

 mssql_query("exec usp_IVR_FormatImportData 79", $conn);
Zhorov
  • 28,486
  • 6
  • 27
  • 52
Joe
  • 1

1 Answers1

0

Check the Data type

or

Convert it.

MSalmanSabir
  • 118
  • 1
  • 9
  • Thanks Salman. The data type in the MS SQL stored procedure is BIGINT. I tried everything from SQLINT1 to VARCHAR and nothing works. – Joe Aug 22 '11 at 13:20