Jump to content

Uncaught PDOException: could not find driver...


Recommended Posts

I chose this category as I thought my topic would best fit here. I am running 14.2 Slackware Linux with the latest version of PHP. In the error log, I receive the error: Uncaught PDOException: could not find driver in 'x file path'. I am positive that I have the required extensions and modules installed and enabled.

Here is my code for the user.php class where I take the user information and add it to the database:


class User {

    public $avatar;
    public $bio;
    public $video_count;
    public $c_status;
    public $username;
    public $password;
    public $email;
    public $doc;
    public $last_logged_in;

    //if ($_SERVER['REQUEST_METHOD'] == 'POST') {

       public function addUser(PDO $pdo) {
	// add user info to db
            $username = $_POST['username'];
            $password = password_hash($_POST['password'], PASSWORD_DEFAULT);
            $bio = $_POST['bio'];
            $email = $_POST['email'];
	    $c_status = 0;
	    $doc = date("Y-m-d h:i:s");
	    // account date last seen/logged in
	    // add account age

	    $query = $pdo->prepare("INSERT into profiles001 (username, password, email, c_status, bio, doc) VALUES (:username, :password, :email, :cstat, :bio, :doc)");

	    $query->bindValue(':username', $username);
	    $query->bindValue(':password', $password);
	    $query->bindValue(':email', $email_address);
	    $query->bindValue(':doc', $doc);
	    $query->bindValue(':bio', $bio);
	    $query->bindValue(':cstat', $c_status);

	    // create variables
	    // initialize variables
	    // bind values of variables being entered into database

      // addUser($pdo);

	// isLoggedIn - checks if user is logged in or not
	// getUser - returns/gets user???

	// avatar
	// bio
	// registration date
	// video count
	// last logged in
	// username
	// email address



Here is my code for the dbcon.php class where the database connection is made:

$host   = "localhost";
$database = "soapbox";
$username = "drb";
$password = "m1n3craft";

// Create connection
    try {
        $pdo = new PDO('mysql:host=localhost;dbname=soapbox;', $username, $password);
    } catch (PDOExcpetion $e) {
	    print "Error!: " . $e.getMessage() . "<br/>";

Print error message and or code to the screen if there is an error.



and the code for the confirmation.php class where the data is displayed temporarily:


    $user = new User();
	// if username exists do not continue...

<!DOCTYPE html>
			<title>soapbox - confirmation</title>
                            $username = $_POST['username'];
                            $email = $_POST['email'];

                            $format = "The data provided has been sent to the server and is being inserted into the database. In order to complete the process, %s, we need you to confirm your account. If not confirmed, your account will be deleted a month from the marked registration date. We have sent you an email at %s, the provided email upon registration. Thank you and cheers! - The Staff at Soapbox";

                            echo sprintf($format, $username, $email);


Link to comment
Share on other sites

kicken, sqlite and odbc only show up for the enabled drivers. Well, I can take back my earlier claim of being sure that the extensions were enabled. I do have them installed to my knowledge when taking a look at /etc/php.ini, I see among the many extensions: mysql.so, mysqli.so, pdo.so, pdo_mysql.so, pdo_sqlite.so and pdo_odbc.so

Link to comment
Share on other sites

Sometimes there are separate ini files for cli, cgi, and apache modules.  The phpinfo() output will also tell you which php.ini file it's looking at so you know which one to edit.  Look for a line similar to


Loaded Configuration File     /etc/php/7.2/fpm/php.ini


Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.