execut MS SQL stored proc
| From: | Damien Babilon | Date: | Thu, 15 Jul 2004 22:42:15 +0000 |
| Subject: | execut MS SQL stored proc | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-35293@lists.php.net to get a copy of this message | ||
Hi All,
To resolve my last prolem, I've switched of server, I'm now on a WIN2000 ox with PHP 4.8 and Apache 1.3, thanks for your reply
Now....
I try to execute a Stored procedure on a mssql box. The connection is ok, ut I can't get the results.
The stored procedure did'n return a recordset, it return simple text and I did'n find (since more than 5 hours now) how to set my vars in php !!!
Here is the code:
$mssql_host="xxx.xxx.xxx.xxx";
$mssql_username="USER";
$mssql_password="PASSWD";
$mssql_db="DBNAME";
$conn=mssql_connect("$mssql_host","$mssql_username","$mssql_password")
or Die("Couldn't connect to MSSQL Server $mssql_host");
mssql_select_db("$mssql_db",$conn)
or Die("Couldn't open database $mssql_db");
$proc=mssql_init("sp_WebCustomerGet",$conn);
$rc=0;
$userid="damien";
$lang="";
$pin="";
$fma="";
$fmtn="";
$res="";
mssql_bind($proc,"@RC",$rc,SQLINT1,TRUE,FALSE);
mssql_bind($proc,"@Id",$userid,SQLVARCHAR,FALSE,20); # <= the param I give to the SP
mssql_bind($proc,"@Language",$lang,SQLCHAR,TRUE,FALSE,5);
mssql_bind($proc,"@Pin",&$pin,SQLCHAR,TRUE,FALSE,4);
mssql_bind($proc,"@FollowMeActive",$fma,SQLBIT,TRUE,FALSE);
mssql_bind($proc,"@FollowMeTelephoneNumber",$fmtn,SQLVARCHAR,TRUE,TRUE,25);
mssql_bind($proc,"@Result",$res,SQLVARCHAR,TRUE,TRUE,256);
$rs=mssql_execute($proc);
echo "Return code:".$rc."<br>";
echo "Lang = ".$lang."<br>";
echo "Pin = ".$pin."<br>";
echo "FollowMeActive = ".$fma."<br>";
echo "FollowMeTelephoneNumer = ".$fmtn."<br>";
echo "Result = ".$res;
Here is the result of the SP with Query analyser:
(1 row(s) affected)
Stored Procedure: EuroGSMTest.dbo.sp_WebCustomerGet
Return Code = 0
Output Parameter(s):
@Language = fr-BE
@Pin = 4321
@FollowMeActive = 0
@FollowMeTelephoneNumber = <NULL>
@Result = Ok