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

  • SEARCH
  • Home
  • 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 8600347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:35:48+00:00 2026-06-12T01:35:48+00:00

I’m trying to use a stored procedure to query some data from my database,

  • 0

I’m trying to use a stored procedure to query some data from my database, but I’m getting the results twice for each field.

The stored procedure looks like this (creation code):

PROCEDURE [dbo].[msp_Query_Information]
@category_id tinyint
AS
BEGIN
        SET NOCOUNT ON;
        SELECT  ,[Name]
                ,[Status_ID]
                ,CONVERT(char(19), [Update_Time], 120)
                ,[Max_Value]
                ,[Current_Value]
        FROM [dbo].[MyTable]
        WHERE [Category_ID] = @category_id
END

I’m using the following PHP to call the stored procedure (minus error checks and debug code):

<?php
    //define db connection
    $serverName = '(local)';
    $connectionInfo = array("Database"=>"MyDatabase");

    //connect to database
    $dbConn = sqlsrv_connect($serverName, $connectionInfo);

    //execute procedure to query servers status
    $spSql = "{call [dbo].[msp_Query_Information](?)}";
    $id = 2;
    $params = array($id);

    $result = sqlsrv_query($dbConn, $spSql, $params);

    //show results
    while ($row = sqlsrv_fetch_array($result))
    {
        foreach ($row as $key => $value) 
        {
            echo $value.'<br/>';
        }
    }

    //close connection to database
    $closeConn = sqlsrv_close($dbConn);

    echo '<br/>Database connection closed.';
?>

These are the results I’m getting:

TEST
TEST
2
2
2012-09-30 16:03:00
2012-09-30 16:03:00
200
200
0
0

There is only one record in MyTable, with Category_ID set to 2. All the data is correct, I’m simply getting it twice.

Am I doing something wrong here?

Is it a normal behaviour and I’m simply too much of a newbie to know?

  • 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-06-12T01:35:50+00:00Added an answer on June 12, 2026 at 1:35 am

    Revise fetchType:

    while ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC ))
    

    Quoting doc:

    A predefined constant specifying the type of array to return. Possible
    values are SQLSRV_FETCH_ASSOC, SQLSRV_FETCH_NUMERIC, and
    SQLSRV_FETCH_BOTH (the default).

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.