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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:09:55+00:00 2026-05-11T13:09:55+00:00

So I’m setting up an installer for my web app, and have input fields

  • 0

So I’m setting up an installer for my web app, and have input fields for database credentials. Part of my validation process includes testing the database connection (using PHP’s PDO library). If the connection fails, I want to be able to differentiate between a bad password, bad address, nonexistent database name, etc. so I can reference the proper input field on the form.

Can anone point me towards a reference that outlines the possible error codes/messages that are returned with a PDOException?

Edit: It occurred to me that these error codes/messages are probably database-specific and the native database codes/errors may simply be getting passed through. If this is the case, I am currently only working with MySQL 5 databases.

  • 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. 2026-05-11T13:09:56+00:00Added an answer on May 11, 2026 at 1:09 pm

    The MySQL documentation is the complete reference for error codes.

    Error codes starting at 1000 are server errors. These include errors like:

    • Error: 1045 SQLSTATE: 28000 (ER_ACCESS_DENIED_ERROR) Message: Access denied for user ‘%s’@’%s’ (using password: %s)

    • Error: 1049 SQLSTATE: 42000 (ER_BAD_DB_ERROR) Message: Unknown database ‘%s’

    Error codes starting at 2000 are client errors. These include errors like:

    • Error: 2005 (CR_UNKNOWN_HOST) Message: Unknown MySQL server host ‘%s’ (%d)

    • Error: 2003 (CR_CONN_HOST_ERROR) Message: Can’t connect to MySQL server on ‘%s’ (%d)

    I’m not going to list all possible errors, because they’re already documented, and I don’t know which ones you need to handle. For instance, errors 2001 and 2002 are specific to UNIX socket connections, which may be irrelevant to your target platform.

    Don’t forget to use PDO::errorCode() and PDO::errorInfo() instead of simply the PDOException message.


    Re your comment about getCode() — No, it doesn’t seem to be supported in that way. I did a quick test, to var_dump() a PDOException. Unfortunately, its code is simple ‘0’ even though the error code and SQLSTATE are included in the exception message.

    Exception::getCode() is part of the base Exception class, as of PHP version 5.1.0. It’s up to the respective PDO driver implementation to utilize this object field. At least for the MySQL driver, they apparently didn’t.

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

Sidebar

Ask A Question

Stats

  • Questions 108k
  • Answers 108k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The destructor for the base class must be called when… May 11, 2026 at 9:14 pm
  • Editorial Team
    Editorial Team added an answer As far as I know the pure java API is… May 11, 2026 at 9:14 pm
  • Editorial Team
    Editorial Team added an answer To add to what Shog9 said, if your application could… May 11, 2026 at 9:14 pm

Related Questions

So I'm getting a new job working with databases (Microsoft SQL Server to be
So I have a Sybase stored proc that takes 1 parameter that's a comma
So I'm embarking on an ASP.NET MVC project and while the experience has been
So I've got a JPanel implementing MouseListener and MouseMotionListener : import javax.swing.*; import java.awt.*;
So I wrote some perl that would parse results returned from the Amazon Web

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.