Why can't I connect pdo enabled under wamp?

Source: Internet
Author: User
& Amp; lt ;? Phptry {code ...}} catch (PDOException $ e) {code ...}} this is the error message couldnotfinddriver. The error file G: wampwwwbstwuxianji. php error line 6 error no. 0 has been enabled in the wamp configuration item

Try {

$ Dsn = "host = localhost; mysql: dbname = jiahua"; // tell the host and the database type to operate are mysql and database name $ user = 'root '; // username $ psw = "123456"; // password // get new PDO (host = localhost; mysql: dbname = jiahua, 'root', 123456 ); $ pdo = new PDO ($ dsn, $ user, $ psw); // It is actually equivalent to mysql_connect ($ host, $ user, $ pw) $ pdo-> setAttribute (PDO:: ATTR_ERRMOTE, PDO: ERRMOTE_EXCEPTION); // sets the error mode var_dump ($ pdo); die (); // executes the insert statement $ SQL = "insert into login (username, password) values (?,?) "; $ Stmt = $ pdo-> prepare ($ SQL); // The prepared statement returns a preprocessing object; var_dump ($ stmt );

} Catch (PDOException $ e ){

Echo "error message". $ e-> getMessage ()."
"; // Get error message echo" error file ". $ e-> getFile ()."
"; // Obtain the abnormal file echo" error line ". $ e-> getLine ()."
"; // Get the error line echo" error code ". $ e-> getCode (); // get the error code

}

This is a prompt
Error message cocould not find driver
Error file G: \ wamp \ www \ bst \ wuxianji. php
Error line 6
Error code 0

Enabled in the wamp configuration item

Reply content:

Try {

$ Dsn = "host = localhost; mysql: dbname = jiahua"; // tell the host and the database type to operate are mysql and database name $ user = 'root '; // username $ psw = "123456"; // password // get new PDO (host = localhost; mysql: dbname = jiahua, 'root', 123456 ); $ pdo = new PDO ($ dsn, $ user, $ psw); // It is actually equivalent to mysql_connect ($ host, $ user, $ pw) $ pdo-> setAttribute (PDO:: ATTR_ERRMOTE, PDO: ERRMOTE_EXCEPTION); // sets the error mode var_dump ($ pdo); die (); // executes the insert statement $ SQL = "insert into login (username, password) values (?,?) "; $ Stmt = $ pdo-> prepare ($ SQL); // The prepared statement returns a preprocessing object; var_dump ($ stmt );

} Catch (PDOException $ e ){

Echo "error message". $ e-> getMessage ()."
"; // Get error message echo" error file ". $ e-> getFile ()."
"; // Obtain the abnormal file echo" error line ". $ e-> getLine ()."
"; // Get the error line echo" error code ". $ e-> getCode (); // get the error code

}

This is a prompt
Error message cocould not find driver
Error file G: \ wamp \ www \ bst \ wuxianji. php
Error line 6
Error code 0

Enabled in the wamp configuration item

Now, you need to expand the pdo.
Download a pdo dll file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.