| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2007-03-23 10:29 UTC] lh at moranti dot com
 Description:
------------
I have a problem executing a stored procedure. 
It fails on my ubuntu installation with php 5.2.1 but when i run it with php 5.1.6 no problem.
Reproduce code:
---------------
mssql_select_db("dbname", $conn);
$sp = mssql_init("procedurename", $conn); // stored proc name
	$compId=1000;
	$SessionId = substr(session_id(),0,8);
	
	mssql_bind($sp, "@CompID",$compId,SQLVARCHAR);
	mssql_bind($sp, "@SessionID",$SessionId,SQLVARCHAR);
	mssql_bind($sp, "@BasketAmount",$BasketAmount,SQLVARCHAR,TRUE);
	mssql_bind($sp, "@BasketTotalItem",$BasketTotalItem,SQLVARCHAR,TRUE);
	$query  = mssql_execute($sp) or die("could not perform insert");
Actual result:
--------------
Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in /home/www/sitename/test_init.php on line 14
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 09:00:01 2025 UTC | 
The storedprocedure looks like this: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go CREATE PROCEDURE [dbo].[test] ( @sval int ) AS return @sval+10 And the php code looks like this <? $conn = mssql_connect("host","user","pass"); mssql_select_db("dbscheme", $conn); $sp = mssql_init("test", $conn); // stored proc name $query = mssql_execute($sp) or die("oops"); ?> is fails in this line "$query = mssql_execute($sp) or die("oops");"Sorry the code schould look like this <? $conn = mssql_connect("host","user","pass"); mssql_select_db("dbscheme", $conn); $int=10; $sp = mssql_init("test", $conn); // stored proc name mssql_bind($sp, "@sval ",$int,SQLINT4); $query = mssql_execute($sp) or die("oops"); ?>I've tested your sample code and it works just fine om my system. I did modify it to get the return value back though: $int=10; $sp = mssql_init("test", $con); // stored proc name mssql_bind($sp, "@sval", $int, SQLINT4); mssql_bind($sp, "RETVAL", $ret, SQLINT4); $query = mssql_execute($sp) or die("oops"); echo "$ret\n"; mssql_close($con);