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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:20:24+00:00 2026-05-21T11:20:24+00:00

I have a logic error I cannot for the life of me figure out.

  • 0

I have a logic error I cannot for the life of me figure out. The problem is this very very basic login page I have written is always outputting the default answer as opposed the the choice from the table.

I am trying to return to the php the value in E_Type in this case the value should return A, however it is not.

What am I doing wrong?

Code:

<?php
$server   = -Removed;
$login    = -Removed;            
$pass     = -Removed;        
$login    = $_POST['login'];
$password = $_POST['password'];
$table    = 'USERPASS';
$table2   = 'EMPLOYEES';
$res      = 'q';

$dblink = @mssql_connect(-Removed) or die("Error 1");
mssql_select_db('group5', $dblink) or die( "unable to select the database");

$sqlquery = "SELECT E_TYPE FROM USERPASS U, EMPLOYEES E WHERE U.EMPLOYEE_ID = E.EMPLOYEE_ID AND PASSWORD = '$password' AND USERNAME = '$login'";
$res = mssql_query($sqlquery, $dblink) or die("Error5");
$count = mssql_num_rows($res);

if($count==1)
{
    if ($res == "A" )
    {
        echo "Success 1";
    }
    else if ($res == "B" )
    {
        echo "Success 2";
    }
    else
    {
        echo "Error...";
    }
}
?>
  • 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-21T11:20:25+00:00Added an answer on May 21, 2026 at 11:20 am

    You need to fetch the result first. In $res you basically only have a result handle that can iterate over the results.

    Use mssql_fetch_assoc to fetch the results and access them (this would loop over all resulting rows):

    while(($row = mssql_fetch_assoc($res)) !== FALSE) {
        echo $row['E_TYPE'];
    }
    

    In your case (if you only expect a single row) use this:

    if($count == 1) {
        $row = mssql_fetch_assoc($res);
        if ($row['E_TYPE'] == "A" )
        {
            echo "Success 1";
        }
        else if ($row['E_TYPE'] == "B" )
        {
            echo "Success 2";
        }
        else {
            echo "Error...";
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TextView that displays an error message in the login page of
I have implemented the .NET Login functionality, and I am receiving a JavaScript Error
So here is the problem: I have some logic in my application that will
Here is one very interesting problem. I am using SQL Server 2008. I have
I researched this around and still can't seem to solve this problem. I have
i have a little problem implementing some serialization/deserialization logic. I have several classes that
I have a problem when I update an object. This is the model: class
I have the following code that doesn't compile. I get the error Cannot use
I have authentication logic that uses cookies. The model attributes are initialized from cookies,
I have some logic in a method that operates on a specified type 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.