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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:13:58+00:00 2026-06-16T14:13:58+00:00

Well err, I don’t know what I did wrong…. This code: try { $this->CONN

  • 0

Well err, I don’t know what I did wrong….

This code:

        try {
            $this->CONN = new \PDO('mysql:dbname='.PASTEAES_DBNAME.';host='.PASTEAES_SERVER, PASTEAES_USERNAME, PASTEAES_PASSWORD);
            $this->CONN->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
        } catch(PDOException $e) {
            $this->raiseError('Fatal MySQL error', $e->getMessage());
        }

Reports this to me:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000] [1049] Unknown database 'pasteaes'' in /var/www/pasteaes/common/class.pasteaes.php on line 25

But, as you can see it is clearly in a try and catch block.

The class that this particular piece of code is in is namespaced, which is why I used “\PDO” instead of “PDO” on line two of the code I shared above.

And oh, yeah, I know that the DB doesn’t exist, but I still don’t want this happening in the future (not that it will). I want to handle errors properly 🙁

  • 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-16T14:14:00+00:00Added an answer on June 16, 2026 at 2:14 pm
    catch(\PDOException $e)
          ^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know javascript very well. I can't define a global variable. var data
I have this code and in Firefox is working well, but in Chrome I'am
Here's my ExtJs component. Everything works perfectly.... err well almost everything. I just don't
well i have a configuration like this in the components part of my config
Well, I was trying to fix this program, and I keep getting the errors
im learning how to use the SELECT CASE but i don't understand very well,
I haven't been able to find this anywhere (or I just don't understand it).
Here's my current code. I'm using express and knox, and I don't think I'm
I have one line of code that is throwing an error that I don't
I'm trying to connect to REST web server and I don't know what is

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.