Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6707613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:39:37+00:00 2026-05-26T07:39:37+00:00

I am having a problem getting a result set from my Sql Server 2008

  • 0

I am having a problem getting a result set from my Sql Server 2008 stored procedure when calling it using PHP. When I execute the stored procedure from within sql, I get the results, so I know the issue isnt with the stored procedure(below).
Sql Stored Procedure

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

Here is the PHP code that calls the stored procedure. Note: The connection to the database works, so I know that it isnt the issue.

*PHP Code *

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();

End of PHP Code

So what am I missing guys(and gals too!)?? any help would be greatly appreciated 😀
thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:39:38+00:00Added an answer on May 26, 2026 at 7:39 am

    your code:

    mssql_bind($stmt, "@ThisContactId", $_SESSION['thisContId'], SQLINT4, false, false, 6);
    mssql_bind($stmt, "@ThisQuestionId", $_SESSION['SecQuestion'], SQLINT4, false, false, 2);
    //        scroll right-->>                                                           ^^
    

    what is up with the optional max length parameter? shouldn’t they both be -1 (max len) or just don’t pass them in?? This optional parameter is only valid with strings, see mssql_bind

    if this doesn’t work, your only other options are to echo the parameters in PHP and record them to a log table from within the procedure. This way you can be sure you are sending and receiving the proper values in the procedure.

    EDIT
    creating and inserting into a log from SQL is easy, here’s how:

    create a table:

    CREATE TABLE MyLog (LogID int not null identity(1,1) primary key
                       ,LogDate datetime not null default GETDATE()
                       ,LogValue varchar(max) not null
                       )
    

    Add this in the procedure right after the SET NOCOUNT ON;

    INSERT INTO MyLog 
        (LogValue) 
        VALUES (ISNULL(OBJECT_NAME(@@PROCID), 'unknown')
                   +', '+ISNULL('"'+CONVERT(varchar(15),@ThisContactId)+'"','NULL')
                   +', '+ISNULL('"'+CONVERT(varchar(15),@ThisQuestionId)+'"','NULL')
                   +', '+ISNULL('"'+@ThisAnswer+'"','NULL')
               )
    

    After you run your application use this to see what you get in the log:

    SELECT * FROM MyLog ORDER BY LogID
    

    that should give you a better idea of what the actual parameters SQL Server is using with in the query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problem getting my tooltip to work when using the jQuery load()
I am having a problem getting a list of fields from a query defined
I am having problem in getting reference of Ajax control extender using $find() or
I'm new to LINQ and am having a problem getting proper results from a
i'm running into a strange problem in Microsoft SQL Server 2008. I have a
Having a problem getting a TreeView control to display node images. The code below
I'm having a problem getting access to a database which lives on a remote
I am having a problem getting my project to link with the PhysX libraries
I'm having a problem getting a simple ASP.NET webpage to display. The page contains
I'm having a problem getting a change event to register with the following code:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.