PHP连接数据库模板
<?php
$servername = "119.45.31.120";
$username = "mwst";
$password = "123456";
$dbname = "mwst";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo 1;//连接成功!
}
catch(PDOException $e) {
echo "Error: " . $e->getMessage();
}
$conn = null;
?>