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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:34:02+00:00 2026-05-27T23:34:02+00:00

Hey I’m learning a new way of querying my databases because its meant to

  • 0

Hey I’m learning a new way of querying my databases because its meant to be better and more secure, this i building prepared statements that can be reused.

The problem is this is a different way of looking at it and im not used to it yet and still have some things that aren’t clear to me.

So my script tries to bind three paras to a query to allow a user to login to my site. I am using the same script as before, this used user name and password… This works just fine:

$query = "SELECT *
            FROM user
            WHERE email = ? AND password = ?
            LIMIT 1";

    if($stmt = $this->conn->prepare($query)) 
    {
        $stmt->bind_param('ss', $un, $pwd);
        $stmt->execute();

        if($stmt->fetch()) 
        {
            //$uid = $stmt->fetch(id);
            //$_SESSION['uid'] = $uid;
            $stmt->close();
            return true;
        }
    }

but when i check if the user is admin i doesn’t like it at all:

$query = "SELECT *
            FROM user
            WHERE email = ? AND password = ? AND isAdmin = ?
            LIMIT 1";

    if($stmt = $this->conn->prepare($query)) 
    {
        $stmt->bind_param('ssi', $un, $pwd, $isAdmin);
        $stmt->execute();

        if($stmt->fetch()) 
        {
            //$uid = $stmt->fetch(id);
            //$_SESSION['uid'] = $uid;
            $stmt->close();
            return true;
        }
    }

Also i declare isAdmin as a global private var at the start of the class like so:

private $isAdmin = "1";

So yeah i know that the user i am testing has a 1 for isActive on the database but when it does into this script it returns false.

Like i said i’m new to this style of writing queries so any help would be amazing.

Thanks for the time.

  • 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-27T23:34:03+00:00Added an answer on May 27, 2026 at 11:34 pm

    Okay so i think i’ve got it. I added the isActive var to the function that is using it instead of it being global now it works fine.

    Thanks for you help. Any other tips on the matter would be more than welcome!

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

Sidebar

Related Questions

Hey Guys If I do this in mono touch: var alert = new UIAlertView
Hey all, just wondering what the best way to add this capability was. I
Hey i have been looking around and i cant find a way to get
Hey guys this is my html code: <div class=nakupy> <li class=icn_kategorie><a href=#>Nákupy</a> <div class=sub_menu>
hey guys having this really simple problem but cant seem to figure out have
Hey its really hard to define an exact title for my problem. I am
Hey I just started learning to make application in C# using back-end as sql.
Hey guys i am trying to run this query in my postgres db but
Hey I am trying to figure out what units of time this is measured
Hey all. I've been been trying to figure this out for a while now.

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.