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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:00:11+00:00 2026-06-13T08:00:11+00:00

I’m trying to create a user management system class and one of my functions

  • 0

I’m trying to create a user management system class and one of my functions is to check if a value is in a column in the database. It returns nothing at all.

Here is the relevant information:

require("opperators/connect.php");
class UserManagemen
{
protected $db;

public function __construct(PDO $db)
  {
    $this->db = $db;
  }
public function isInDatabase($checkIfThis, $isHere)
  {
    $stmt = $db->prepare("SELECT 1 from users WHERE $isHere = :$isHere");
    $stmt->execute(array(':$isHere' => $checkIfThis));
        if ($stmt->rowCount() > 0) {
        echo "It's in the database";
        } else {
        echo "Not in the database and you are good to go!";
        }
   }
}
$usermanagement = new UserManagemen($db, null, null, null);
$usermanagement->isInDatabase(Batman, username);

in connect.php: this worked in my procedural coding test.

$configurator['database'] = array(
'username' =>   'root',
'password' =>   'root',
'host' =>    'localhost',
'db' =>    'girlscouts',
);
$options  = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
);
try {
$db = new PDO("mysql:host={$configurator['database']['host']};dbname={$configurator['database']['db']};charset=utf8", $configurator['database']['username'], $configurator['database']['password'], $options);
}
catch (PDOException $ex) { 
die("Failed to connect to the database: " . $ex->getMessage());
}

I apologise in advance if this has been asked repeatedly, I’ve tried a google but returned nothing of value, possibly because I don’t know what to google. I’m not big on asking for help but I’ll give it a shot.

  • 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-13T08:00:16+00:00Added an answer on June 13, 2026 at 8:00 am

    I think it should be

    if ($stmt->rowCount() > 0) { // data available
        echo "It's in the database";
    } else {
        echo "Not in the database and you are good to go!";
    }
    

    instead of

    if ($stmt->rowCount() > 0) {
        echo "Not in the database and you are good to go!";
    } else {
        echo "It's in the database";
    }
    

    Also you didn’t initialize the PDO like new PDO(...);, in your constructor it should be

    $this->db = new PDO(...);
    

    and you should use it like

    $stmt=$this->db->prepare(...);
    $stmt->execute(...);
    

    Take a look at this and this for details.

    • 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'm trying to create an if statement in PHP that prevents a single post
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.