PDO 链接数据库方式
Published
2022-07-07
浏览次数 : 198
//PDO链接数据方式
$sName = '';
$uName = '';
$pass = '';
$dbName = '';
//create database connection
try {
$conn = new PDO("mysql:host=$sName;dbname=$dbName",$uName,$pass);
$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}catch(PDOException $e) {
echo "Connection Failed: " . $e->getMessage();
}
//mysql 链接数据方式
$HOSTNAME = '';
$HOSTADMIN = '';
$HOSTPASSWORD = '';
$HOSTBASE = '';
$conn = new mysqli($HOSTNAME,$HOSTADMIN,$HOSTPASSWORD,$HOSTBASE);
$login = 0;
$inValid = 0;
if (!$conn) {
die(mysqli_error($conn));
}
- 标签1
- 标签1
- 标签1