好的,所以我设法安装了驱动程序,并从网站复制并粘贴了连接测试php。这是代码:
<?php
$hostname = '(LocalDb)\v11.0';
$connection_options = array('Database'=>'MagicFountainMedia2014', 'UID'=>'home\SQL', 'PWD'=>'');
$conn = sqlsrv_connect($hostname, $connection_options);
if(!is_resource($conn)){ echo 'Could not connect: '; var_dump(sqlsrv_errors(SQLSRV_ERR_ALL)); exit(0); }
echo 'Connection established successfully.';
sqlsrv_close($conn);
?>
我已经更改了相应的变量(据我所知)但是当我在我的apache服务器(XAMMP)上运行PHP时,它会将其转储到浏览器中:
Could not connect: array(2) { [0]=> array(6) { [0]=> string(5) "28000" ["SQLSTATE"]=> string(5) "28000" [1]=> int(18456) ["code"]=> int(18456) [2]=> string(87) "[Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'home\SQL'." ["message"]=> string(87) "[Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'home\SQL'." } [1]=> array(6) { [0]=> string(5) "28000" ["SQLSTATE"]=> string(5) "28000" [1]=> int(18456) ["code"]=> int(18456) [2]=> string(87) "[Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'home\SQL'." ["message"]=> string(87) "[Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'home\SQL'." } }
有没有人知道什么是错的?这将是一个巨大的帮助!
提前致谢!