1

I am trying to execute a stored procedure from php.

In the php code iam sending a integer parameter to the stored procedure

$orderId =824;
$result =mssql_bind($sp, "@orderID", $orderId, SQLINT1, true, false);

I getting an error

mssql_execute() [function.mssql-execute]: message: The formal parameter "@orderID" was not declared as an OUTPUT parameter, but the actual parameter passed in requested output. (severity 16)

Can any one say the reason please

2 Answers 2

3

The document of mssql_bind gives the signature of it as:

bool mssql_bind  ( resource $stmt  , string $param_name  , mixed &$var  , int $type  [, bool $is_output = false  [, bool $is_null = false  [, int $maxlen = -1  ]]] )

So your problem is you're setting $is_output as true.

Use

$orderId =824;
$result =mssql_bind($sp, "@orderID", $orderId, SQLINT1, false, false);
Sign up to request clarification or add additional context in comments.

4 Comments

I suspect so, as Linto says "sending an integer parameter to the stored procedure"
i got everything working ,but one problem.When i sent small oderid(eg 1,225,100,596,..)it works but when i sent big order id eg(100303),it not giving output, eventhough there is records for this order.So i changed the type parameter of mssql_bind with all most all , then i will get the result with a warning "Warning: mssql_execute() [function.mssql-execute]: WARNING! Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?'). (severity 16)".Do you have any idea
Your problem is the SQLINT1 data type. See php.net/manual/en/mssql.constants.php. SQLINT1 is a single byte, -128 to 127. Use SQLINT4 instead.
Thank you very much SamStephens .My problem is over
0

You must create your stored procedure so that it indicates that the parameter as an OUTPUT variable.

DECLARE MyProc (@orderID int OUTPUT) AS ...

4 Comments

so do i need to create that particular stored proceedure in php code?i mean the stored proceedure from the sql server
No. If the stored procedure needs to have the @orderID parameter as an output parameter, you would alter it using the same technique/tool in which it was created. Are you expecting the stored procedure to send the @orderID value to your PHP code? If No, then you want to look at @SamStephens answer and leave the procedure unchanged.
i got everything working ,but one problem.When i sent small oderid(eg 1,225,100,596,..)it works but when i sent big order id eg(100303),it not giving output, eventhough there is records for this order.So i changed the type parameter of mssql_bind with all most all , then i will get the result with a warning "Warning: mssql_execute() [function.mssql-execute]: WARNING! Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?'). (severity 16)".Do you have any idea
Hi bobs , i got the answer for last question from SamStephens Thank you very much bobs for your interest too.My problem is over

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.