0

When I try to insert into a table from textbox, I get this error:

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\wamp\www\php\login\data\DB\Users\UsersTbl.php on line 15 ( ! ) PDOException: could not find driver in C:\wamp\www\php\login\data\DB\Users\UsersTbl.php on line 15

I tried to check php.ini:

extension_dir = "c:/wamp/bin/php/php5.5.12/ext/"
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
extension=php_shmop.dll

PHP file:

<?php

class usersTbl {

    private $colNames;

    public function __construct() {
        $this->colNames = array("id", "fname", "lname", "email", "password", "rpassword");
    }

    public function insert(array $data) {
        $pdo = new PDO("mysql:host=" . "localhost" . ";dbname=" . "test" . ";charset= utf8", "root", "", array(PDO::ATTR_PERSISTENT => true));

        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sql = " INSERT INTO persons (fname,lname,email,password,rpassword) VALUES(?,?,?,?,?)";
        $stmt = $pdo->prepare($sql);
        $stmt->execute(array($data['fname'],$data['lname'],$data['email'], sha1($data['password']),$data['rpassword']));
    }
}

PHP version: 5.5.12

Any ideas?

  • Please try and use google searching before asking a question. Put it another way, do you *really* think that in all the years `PDO` has existed in MySQL / PHP that this event has 1) never been seen before or 2) not been asked on StackOverflow before? – Martin Dec 20 '17 at 13:01
  • 1) Try to restart apache. 2) Remove the space after `PDO("mysql` 3) Move `PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION` to the PDO constructor. – odan Dec 20 '17 at 13:01
  • edit my code @DanielO.??? – Korosh Man1989 Dec 20 '17 at 13:49
  • Then maybe use XAMPP :) – odan Dec 20 '17 at 14:44

0 Answers0