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 8597007
In Process

The Archive Base Latest Questions

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

I am developing a webservice using php and MSSQL.I could connect with db and

  • 0

I am developing a webservice using php and MSSQL.I could connect with db and retriev values.But when I use json,It will return no values.

The ajax code used for web service is

    $.ajax({
        url: 'http://209.249.81.138/dev/logintalk.php',
        type: 'POST',
        data: "username=" + $("#username").val()+"&password=" + $("#password").val(),
        dataType: 'json',
        success: function(data){
            alert(data);
        },
        error: function(){
            alert("failure...");
        }
       });
}

and the php code used is

<?php

    $server = "server";
    $username = "username";

    $password = "secret";
    $database = "db";

    $con = mssql_connect($server, $username, $password) or die("Couldn't connect to SQL Server on $Server");

    $users = $_POST['username'];
    $passwd = $_POST['password'];

    $selected = mssql_select_db($database, $con) or die("Couldn't open database $database");

    mssql_query('SET CHARACTER SET utf8'); 
    $query = "SELECT * FROM zNewUsers WHERE memberid = '$users' AND userid = '$passwd'";
    $result = mssql_query($query) or die ("Unable to verify user because ");
    $row = mssql_fetch_array($result);
    $count = mssql_num_rows($result);

    if($count == 0){
        $data=array(0=>"Incorrect values...");
        $value[]=$data[0];
        echo json_encode($value);
    }
    else{
    $val[]=$row['SessionID'];
    echo json_encode($val);
    }  
    mssql_close($con);

?>
  • 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-12T00:48:57+00:00Added an answer on June 12, 2026 at 12:48 am

    Few tips beyond question:

    1. success: function(data){
          console.log(data);
          //This is better for debugging if you use firebug, if you don't do it.
      },
      
    2. if($count == 0){
          echo json_encode(array(0=>"Incorrect values..."));
          //Why create new variables? Pass what you want directly to json_encode()
      }
      else{
          echo json_encode($row['SessionID']);
      }
      

    Back to question:

    var_dump() data you want to encode before encoding and make sure it’s OK, then check what you get in browser by console.log(data) and share this information with us so we could help better.

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

Sidebar

Related Questions

I'm developing a .NET 3.5 webservice using .asmx pages, but the fact that i
I've spent the last week developing code to connect to a Web Service using
I'm developing a webservice using a WSDL (contract-first) that defines one of it's fields
I am developing an ecommerce app that is using the UPS shipping webservice. I
I am currently developing a RESTful Webservice in Java using the Jersey library. For
I am developing one webservice using c#.It is possible intercept the client request using
I am developing a restful webservice using grails for first time and I following
I’ve been developing a vb.net client that connects to a Webservice using SOAP. This
I'm developing an asp.net webservice application to provide json-formatted data to a widget that
I'm developing a web application using .net/c#/jQuery. I want to develop an AJAX function

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.