Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2004071

[PHP-DB] execut MS SQL stored proc From: Damien Babilon (damien <email protected>)
Date: 07/15/04

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," <email protected>",$rc,SQLINT1,TRUE,FALSE);
   mssql_bind($proc," <email protected>",$userid,SQLVARCHAR,FALSE,20); # <= the param
I give to the SP
   mssql_bind($proc," <email protected>",$lang,SQLCHAR,TRUE,FALSE,5);
   mssql_bind($proc," <email protected>",&$pin,SQLCHAR,TRUE,FALSE,4);
   mssql_bind($proc," <email protected>",$fma,SQLBIT,TRUE,FALSE);
   
mssql_bind($proc," <email protected>",$fmtn,SQLVARCHAR,TRUE,TRUE,25);
   mssql_bind($proc," <email protected>",$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):
        <email protected> = fr-BE
        <email protected> = 4321
        <email protected> = 0
        <email protected> = <NULL>
        <email protected> = Ok

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php