?????????????????
????????phpinfo.php??????????????????????????????????????????????mySql???????????

??????c?????php.ini???????????????mySql???????????????????????

?????????????
<?php
//?????????
$dsn="mysql:dbname=test;host=127.0.0.1";//???????
$user="root";//username
$password="715632";//????
try{
$pdoConn=new PDO($dsn??$user??$password);
echo "???????????";
}catch(PDOException $e){
echo "????????????".$e->getMessage();
exit;
}
?????????
<?php
//?????????
$dsn="mysql:dbname=test;host=127.0.0.1";//???????
$user="root";//username
$password="715632";//????
try{
$pdoConn=new PDO($dsn??$user??$password);
echo "???????????"."<br/>";
}catch(PDOException $e){
echo "????????????".$e->getMessage();
exit;
}
try{
//???????
/*$sql="insert into contacts(name??telno??email) values(???????)";
$ptmt=$pdoConn->prepare($sql);
$name="liujun";
$telno="347535420";
$email="liujun@qq.com";
$ptmt->bindParam(1??$name);
$ptmt->bindParam(2??$telno);
$ptmt->bindParam(3??$email);
$result=$ptmt->execute();
echo "?????????".$result;
*/
//???????
$sql="select * from contacts";
$ptmt=$pdoConn->prepare($sql);
$result=$ptmt->execute();
if($result==1){//???н????
while($list=$ptmt->fetch()){
echo $list['name']."-----".$list['telno']."----".$list['email']."<br/>";
}
}
}catch(PDOExcepton $e){
echo "???????????";
exit;
}