我正在尝试从joomla网站到服务器管理工作室数据库的简单数据库连接。我尝试了几种不同的方式,srv,dbo等。 它仍以最简单的形式显示错误。 是否有可能建立这种联系?
错误讯息:
Unable to load Database Driver: mssql
Uncaught Error: Call to undefined function mssql_connect()
Call to undefined function sqlsrv_connect()
简单的:
<?php
// Create a link to MSSQL
$con = mssql_connect('server1', 'name', 'pass');
// Select the database 'php'
mssql_select_db('database1', $con);
?>
way2:
<?php
$servername = "s1";
$username = "u1";
$password = "p1";
try {
$conn = new PDO("sqlsrv:Server=$servername;Database=db1", $username, $password);
// set the PDO error mode to exception
$setAttribute = $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>