<?php
$dbhost ="localhost";
$dbuser = "root";
$dbpwd = "123";
$dbname = "mydatabase";
$charName = "utf8";
try {
$conn = new PDO("mysql:host=$dbhost;port=3306;dbname=$dbname", $dbuser, $dbpwd, array(PDO::MYSQL_ATTR_INIT_COMMAND => "set names utf8"));
//echo "数据库链接成功!";
}
catch(PDOException $e){
echo $e->getMessage();
}
?>
php pdo 连接MySQL数据库
最新推荐文章于 2022-08-16 19:12:46 发布