我在使用PHP调用它时从我的Sql Server 2008存储过程获取结果集时出现问题。当我在sql中执行存储过程时,我得到结果,所以我知道问题不在于存储过程(如下所示)。 SQL存储过程SQL存储过程/ Php问题
USE [HRAPPS]
GO
/****** Object: StoredProcedure [dbo].[sp_GetSecurityAnswer] Script Date: 10/21/2011 08:38:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_GetSecurityAnswer]
(
@ThisContactId INT, @ThisQuestionId INT, @ThisAnswer varchar(255)
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT
a.Cont_id,
a.QuestionId
FROM dbo.sec_answers a
WHERE a.cont_id = @ThisContactId and
a.QuestionId = @ThisQuestionId and
lower(a.Response) = lower(@ThisAnswer)
END
这里是PHP代码调用存储过程。注意:与数据库的连接有效,所以我知道它不是问题。
* PHP代码*
if(!$dbCon=mssql_connect(DBHOST,DBUSER,DBPASS))
{
$error = "Unable to Connect to Database. Please Try Again Later.";
}
else
{
$stmt = mssql_init("sp_GetSecurityAnswer", $dbCon);
mssql_bind($stmt, "@ThisContactId", $_SESSION['thisContId'], SQLINT4, false, false, 6);
mssql_bind($stmt, "@ThisQuestionId", $_SESSION['SecQuestion'], SQLINT4, false, false, 2);
mssql_bind($stmt, "@ThisAnswer", $_SESSION['ThisAnswer'], SQLVARCHAR, false, false, 255);
$Security_Verification_Result = mssql_execute($stmt, false);
IF(!mssql_num_rows($Security_Verification_Result))
{
ECHO "You have Incorrectly answered your selected Security Verification Question, Please go back and try again";
EXIT();
}
ELSE
{
header("Location: some_url?userfullname=".$_SESSION['userfullname'] .'&cont_id='.$_SESSION['ThisContId']);
}
}
exit();
PHP代码的结束
所以我缺少什么家伙(和加尔斯呢!)?任何帮助将不胜感激:d 由于事先
你得到了什么输出,你期望什么? – ObscureRobot
小心告诉我们问题是什么?错误消息,意外输出等? – MatBailie
你是否回应出你的'$ _ SESSION ['...']'值,以确保你实际上传递了与你认为相同的值? –