& 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