tags:

views:

23

answers:

1

Hi

I have a stored Proceedure 'spGetOrderByID' in the sql server.

Which gives a record according the given order id.

And the stored proceedure is working fine , while i trying in the sql server.

This is the php code iam using

$this->_connectionString = mssql_connect($host, $username, $password) or die("can't connect to server1");
$this->_dbName ='databaseName";
$selectDB = mssql_select_db($this->_dbName, $this->_connectionString ) or die('Databse error'); 

$sp = mssql_init('spGetOrderByID',  $this->_connectionString);
$orderId =824;

mssql_bind($sp, "@orderID", $orderId, SQLINT1, false, false);
mssql_execute($sp,$this->_dbName);

echo $orderId;

1: let me know the result of the sored proceedure will be in $orderId, right?

2: Do i need to set a any new setting in php, for the stored proceedure to working.But already i can connect the ms sql server successfully

3: Now i getting Warning: mssql_execute(): stored procedure execution failed

Please advise me

+1  A: 

You use the msql_bind command. As such:

$sp = mssql_init('stored_p', $db);
mssql_bind($sp, "@varInput", $input, VARCHAR, false, false);
mssql_execute($sp,$db);

Where varInput corresponds to an input var declared in the stored procedure. Output vars can be assigned in a similar fashion. You can assign multiple input and output vars by making multiple msql_bind commands, binding different PHP vars to different stored procedure vars.

For more info and examples, visit http://php.net/manual/en/function.mssql-bind.php

Goat Master
thank you very much ,let me check with that
Linto P D
how can i get the result of stored procedure
Linto P D
If you use mssql_bind on an output paramater then the php variable binded will then contain the stored procedure's output variable
Goat Master
Hi, can you please check my question description again.I have changed the description and please advice
Linto P D