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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:54:19+00:00 2026-06-03T11:54:19+00:00

I currently have a database call which works in one area, but not another.

  • 0

I currently have a database call which works in one area, but not another.

My database class is labeled $database and has the $db PDO object passed to the database constructor.

This all works fine.

This code call works

$user_info = $database->get_user($user);

This function is called

public function get_user($user){
        $user = $this->db->quote($user);
        $query = "SELECT * FROM login where username = $user";
        $user = $this->db->query($query);
        $user_info = $user->fetch();
        return $user_info;}

This returns the user info as expected

Another call is

        $user = $database->confirm($confirm);
        $user_info = $database->get_user($user);

The confirm function looks like this

        public function confirm($confirm){
        $confirm = $this->db->quote($confirm);
        $query = "SELECT * FROM temp_data WHERE hash = $confirm;";
        $count = $this->db->query($query);
        $info = $count->fetch();

        $user = $info['username'];
        $user = $this->db->quote($user);
        $query = "DELETE FROM temp_data WHERE username = $user;";
        $this->db->exec($query);
        $query = "UPDATE login SET confirm = '1' WHERE  username = $user;";
        $this->db->exec($query);
        return $info['username'];}

This call works perfectly.

It returns the username in an unquoted format which the get_user accepts

However the get_user fails

I have done troubleshooting and found the issue is that the following line in get_user is not returning any PDO object, or any data at all

$user = $this->db->query($query); 

This is the interesting part. I did a try catch and the PDO is throwing no PDO exception and it is not even throwing a general exception. There are no errors in the error log. It just appears not to be working. I have went through step by step using Print_r, get_class, and echo followed by a die; to output my results and it all works up until I do the second database call. The fetch is returning an error, but that is only due to the fact the exec is not running at all it seems

I did try using unset() on everything but my main DB connection that is created and passed into my database object when it is created

Here is what is happening when the script is run

  1. The user clicks on a link with a random hash
  2. The system gets the hash from the GET and then uses that too pull the user name from the temp database.
  3. It then modifies the user as confirmed, deletes the temp entry and then returns the user name
  4. from here it then calls the get_user. In this case it just returns the user information to set up the twilio sub account. This is where the system is failing
  5. After that what happens (And this it does try to do from my testing because i get an error here) is that it accesses the twilio API, gets a sub acount AUTH and SID token and writes it to the users file
  6. Then the new user is redirected to the signin page

I have tried using close cursor and it has not worked.

If anyone can give me any insight into the issue I am having, or what I am doing wrong I would appreciate it. I am new to using the PDO object so I am sure I have made a stupid mistake somewhere.

  • 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-03T11:54:20+00:00Added an answer on June 3, 2026 at 11:54 am

    I was able to get the answer from a great guy at the PHPFreaks IRC channel.

    public function get_user($user){
            $stmt = $this->db->prepare('SELECT * FROM login where username = :u');
            $stmt->bindValue(':u', $user);
            $stmt->execute();
    
            $user_info = $stmt->fetch();
            $stmt->closeCursor();
    
            return $user_info;
    }
    
    
    public function confirm($confirm){
            $stmt = $this->db->prepare('SELECT * FROM temp_data WHERE hash = :h');
            $stmt->bindValue(':h', $confirm);
            $stmt->execute();
            $info = $stmt->fetch();
            $stmt->closeCursor();
    
            $stmt = $this->db->prepare('DELETE FROM temp_data WHERE username = :u');
            $stmt->bindValue(':u', $info['username']);
            $stmt->execute();
    
            $stmt = $this->db->prepare('UPDATE login SET confirm = '1' WHERE  username = :u');
            $stmt->bindValue(':u', $info['username']);
            $stmt->execute();
    
            return $info['username'];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a database with the following relationships: One Client has multiple Entities
Currently I have database with the following associations: One Client to Many Intakes One
I currently have a MySQL database which I was hoping to use to store
I currently have this code which reads the first field in a database record
I have a class (in C++), call it Data , that has thousands of
I currently have a Postgres 8.4 database that contains a varchar(10000) column. I'd like
I currently have a bunch of SQLCHAR objects from a database query. The query
I currently have a problem attepting to update a record within my database. I
I'm trying to normalize a mysql database.... I currently have a table that contains
Currently I have a website and database solution, however I would like to take

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.