Wamp Open the PDO why is it not connected

Source: Internet
Author: User

try{

$dsn="host=localhost;mysql:dbname=jiahua";//告诉主机和要操作的数据库类型是mysql 和数据库名$user='root';//用户名$psw="123456";//密码//获取new PDO(host=localhost;mysql:dbname=jiahua,'root',123456);$pdo= new PDO($dsn, $user, $psw);//其实就相当于mysql_connect($host,$user,$pw)$pdo->setAttribute(PDO::ATTR_ERRMOTE,PDO::ERRMOTE_EXCEPTION);//设置错误模式var_dump($pdo);die();//执行插入语句$sql="insert into login (username,password) values(?,?)";$stmt=$pdo->prepare($sql);//准备语句 返回一个预处理对象;var_dump($stmt);

}catch (Pdoexception $e) {

echo"错误信息". $e->getMessage()."
";//获取错误信息echo"错误文件".$e->getFile()."
";//获取异常的文件echo "错误行".$e->getLine()."
";//获取错误行echo "错误号".$e->getCode();//获取错误号

}

This is a hint.
Error message could not find driver
Error file G:\wamp\www\bst\wuxianji.php
Error Line 6
Error number 0

The Wamp configuration item is already open.

Reply content:

try{

$dsn="host=localhost;mysql:dbname=jiahua";//告诉主机和要操作的数据库类型是mysql 和数据库名$user='root';//用户名$psw="123456";//密码//获取new PDO(host=localhost;mysql:dbname=jiahua,'root',123456);$pdo= new PDO($dsn, $user, $psw);//其实就相当于mysql_connect($host,$user,$pw)$pdo->setAttribute(PDO::ATTR_ERRMOTE,PDO::ERRMOTE_EXCEPTION);//设置错误模式var_dump($pdo);die();//执行插入语句$sql="insert into login (username,password) values(?,?)";$stmt=$pdo->prepare($sql);//准备语句 返回一个预处理对象;var_dump($stmt);

}catch (Pdoexception $e) {

echo"错误信息". $e->getMessage()."
";//获取错误信息echo"错误文件".$e->getFile()."
";//获取异常的文件echo "错误行".$e->getLine()."
";//获取错误行echo "错误号".$e->getCode();//获取错误号

}

This is a hint.
Error message could not find driver
Error file G:\wamp\www\bst\wuxianji.php
Error Line 6
Error number 0

The Wamp configuration item is already open.

Open, you have to have PDO expansion.
To download a copy of the 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.