Here is the code to connect PHP with Mssql Server Stored procedure.
<?php
$sqlServerIP = '127.0.0.1';
$link = mssql_connect($sqlServerIP, 'sa', 'amit123');
if (!$link) {
die('wrong connection.');
}
mssql_select_db('amittest', $link);
$stmt = mssql_init('LoginChk');
$ID = 1;
$EmpID = 'Emp001';
$OutputLogin=0;
// Bind values
mssql_bind($stmt, '@ID', $ID, SQLINT4, false, false, 60);
mssql_bind($stmt, '@EmpID', $EmpID, SQLVARCHAR, false, false, 20);
mssql_bind($stmt, '@OutputLogin', $OutputLogin, SQLINT4, true, false, 20);
mssql_execute($stmt);
mssql_free_statement($stmt);
echo $OutputLogin;
echo mssql_get_last_message();
/*
////////////////////////////////////////////////////////
CREATE PROCEDURE dbo.LoginChk
@ID varchar(50),
@EmpID varchar(50),
@OutputLogin bigint OUTPUT
as
begin
IF(EXISTS(select ID,EmpID, from Employee where ID=@ID and EmpID=@EmpID))
begin
--select @OutputFirstName=vFirstName from AdminInfo where vUserId=@UserId and vPassword=@Password
select @OutputLogin =1
End
else
begin
select @OutputLogin =0
End
End
*/
?>
<?php
$sqlServerIP = '127.0.0.1';
$link = mssql_connect($sqlServerIP, 'sa', 'amit123');
if (!$link) {
die('wrong connection.');
}
mssql_select_db('amittest', $link);
$stmt = mssql_init('LoginChk');
$ID = 1;
$EmpID = 'Emp001';
$OutputLogin=0;
// Bind values
mssql_bind($stmt, '@ID', $ID, SQLINT4, false, false, 60);
mssql_bind($stmt, '@EmpID', $EmpID, SQLVARCHAR, false, false, 20);
mssql_bind($stmt, '@OutputLogin', $OutputLogin, SQLINT4, true, false, 20);
mssql_execute($stmt);
mssql_free_statement($stmt);
echo $OutputLogin;
echo mssql_get_last_message();
/*
////////////////////////////////////////////////////////
CREATE PROCEDURE dbo.LoginChk
@ID varchar(50),
@EmpID varchar(50),
@OutputLogin bigint OUTPUT
as
begin
IF(EXISTS(select ID,EmpID, from Employee where ID=@ID and EmpID=@EmpID))
begin
--select @OutputFirstName=vFirstName from AdminInfo where vUserId=@UserId and vPassword=@Password
select @OutputLogin =1
End
else
begin
select @OutputLogin =0
End
End
*/
?>
0 comments:
Post a Comment