We help IT Professionals succeed at work.
Get Started

Executing stored procedure with IN and OUT parameters in PHP

1,474 Views
Last Modified: 2012-05-11
I want to execute a stored procedure into my PHP code, this stored procedure has an IN and an OUT parameter. The stored procedure is this:
 
USE [phl_pmx]
GO

DECLARE	@return_value int

EXEC	@return_value = [dbo].[PMX_SP_RecreateSynonymsOfSourceDb]
		@sourceDb = phl

SELECT	'Return Value' = @return_value

GO

Open in new window


And I already wrote the following code, but it keeps giving errors that he can't execute it, or he just won't show a thing.

Does anyone know how to correct the code and how I can let PHP show me the output parameter?
 
$link = mssql_connect('server', 'sa', 'pass');

$id = 'phl'
mssql_select_db($id,$link);

$proc = mssql_init("PMX_SP_RecreateSynonymsOfSourceDb");
mssql_bind($proc, "@sourceDb", $id, SQLVARCHAR, FALSE);
mssql_execute($proc);
unset($proc);
mssql_close($link);

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 2 Answers and 10 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE