php SQL Server mssql_select_db 错误 [英] php SQL Server mssql_select_db error

查看:38
本文介绍了php SQL Server mssql_select_db 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

直到昨天,我一直很高兴在 IIS 7 上使用 PHP 5 连接到 SQL Server Express 2005.

Up until yesterday I have been happily connecting to SQL Server Express 2005 using PHP 5 on IIS 7.

昨天我开始在选择数据库时出错.

Yesterday I started getting errors when selecting a database.

<?php
$link = mssql_connect('localhost,1433', 'login', 'password');

if(!$link) {
    die('could not connect to MSSQL');
}

 if(!mssql_select_db('database', $link)) {
    echo mssql_get_last_message();
    die('could not select db');    
}    
?>

输出如下:

"将数据库上下文更改为'database'.无法选择数据库"

所以 mssql_get_last_message 正在输出 Changed database context to 'database'. 这似乎都是正确的,并不是真正的错误消息.但随后 mssql_select_db 仍然失败.

So mssql_get_last_message is outputting Changed database context to 'database'. which seems all correct and isn't really an error message. But then the mssql_select_db is still failing.

我已经测试了以下内容:

I have tested the following:

  • 登录正确(您在更改用户名或密码时遇到不同的错误)
  • 数据库存在(如果我使用不存在的数据库的名称,则会出现不同的错误
  • 登录可以连接到数据库(如果在 SQL Server 中删除数据库用户,则会出现不同的错误)

我不确定还要测试什么.

I'm not sure what else to test.

推荐答案

感谢 Martin 和 Phil 的回复.我创建了一个新的登录名和一个新的相应用户来解决这个问题.

Thanks to Martin and Phil for their responses. I created a new login and a new corresponding user which fixed the problem.

这篇关于php SQL Server mssql_select_db 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆