我需要一个php和MS SQL的连接脚本: 在尝试以下但它不起作用
$server = 'MVEKELDG156\SQLEXPRESS'; $username = 'EDUC.PWV.GOV.ZA\Mveke.L';
$password = 'password@'; $database = 'SAMS_EMIS_Warehouses';
if(!mysql_connect($server, $username, $password)) { exit('Error: could not
establish database connection'); } if(!mysql_select_db($database)) {
exit('Error: could not select the database'); }
答案 0 :(得分:1)
通过将extension=php_mssql.dll
添加到php.ini
来启用MSSQL扩展程序。
要使这些函数正常工作,您必须使用--with-mssql [= DIR]编译PHP,其中DIR是FreeTDS安装前缀。并且应该使用--enable-msdblib编译FreeTDS。
更多参考资料:
答案 1 :(得分:0)
检查
$myServer = "localhost";
$myUser = "your_name";
$myPass = "your_password";
$myDB = "SAMS_EMIS_Warehouses";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB