Re: [PHP-DB] execut MS SQL stored proc

2004-07-16 Thread Robert Twitty
Hi Damien

IMHO you should use the odbtp extension to connect to SQL Server
databases, especially on a Win32 platform.  The Win32 version of the mssql
ext uses DB-Library. This library is obsolete, unsupported by MS, and does
not completely support SQL Server databases beyond version 6.5. Also,
because the mssql ext on Linux/UNIX uses FreeTDS, the behaviour of your
scripts may not be the same across all platforms.

I would suggest that you try your script using the odbtp/mssql hybrid ext,
php_odbtp_mssql.dll.  To ensure full compatibility with the mssql ext,
follow the instructions at http://odbtp.sourceforge.net/phpext.html#mssql

Note: If you have not done so already, you should place

SET NOCOUNT ON

at the beginning of your stored procedure(s) to prevent "affected row"
counts from appearing as results. Output parameter data will not
be available until all results have been read.

-- bob

On Fri, 16 Jul 2004, Damien Babilon wrote:

> 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."";
> echo "Lang = ".$lang."";
> echo "Pin = ".$pin."";
> echo "FollowMeActive = ".$fma."";
> echo "FollowMeTelephoneNumer = ".$fmtn."";
> 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 = 
> @Result = Ok
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



[PHP-DB] execut MS SQL stored proc

2004-07-15 Thread Damien Babilon
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."";
  echo "Lang = ".$lang."";
  echo "Pin = ".$pin."";
  echo "FollowMeActive = ".$fma."";
  echo "FollowMeTelephoneNumer = ".$fmtn."";
  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 = 
  @Result = Ok
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] execut MS SQL stored proc

2004-07-15 Thread Damien Babilon
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."";
   echo "Lang = ".$lang."";
   echo "Pin = ".$pin."";
   echo "FollowMeActive = ".$fma."";
   echo "FollowMeTelephoneNumer = ".$fmtn."";
   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 = 
   @Result = Ok
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php