我要开发一个简单的应用程序。我的应用程序将借助PHP Web服务与实时数据库进行通信。在本地测试我的应用程序时,一切都很好。但是当我转移到实时服务器时(我的数据库和Web服务文件托管在Live服务器((即GoDaddy)中)。
<?php
require "db_config.php";
$user_name=$_POST['login_name'];
$user_pass=$_POST['login_pass'];
$sql_query = sqlsrv_query( $conn, "select * from user_auth where user_name='".$user_name."' and user_pass ='".$user_pass."'" , array(), array( "Scrollable" => SQLSRV_CURSOR_KEYSET ));
if(sqlsrv_num_rows($sql_query)>0)
{
echo "Login Success..Welcome";
}
else
{
echo "Login Failed.......Try Again..";
}
?>
这是测试登录活动的代码。我运行后,我收到此错误:
Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18452 [code] => 18452 [2] =>
[Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed.
The login is from an untrusted domain and cannot be used with Windows authentication.
[message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed.
The login is from an untrusted domain and cannot be used with Windows authentication. )
[1] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18452 [code] => 18452
[2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed.
The login is from an untrusted domain and cannot be used with Windows authentication.
[message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. ) )
我在本地获取此问题时更改我的本地SQL Management Studio软件中的某些配置,并且我也可以使用一些DLL文件(如在PHP.ini文件中进行更改)
extension=php_pdo_sqlsrv_55_ts.dll
extension=php_sqlsrv_55_ts.dll
这是本地机器,但是当我使用实时数据库时,如何配置我的在线数据库?如果有任何可能的方法来使用DLL文件,如本地机器?如果不是如何配置?
db_config.php
<?php
$serverName = "servername";
$connectionInfo = array( "Database"=>"testdb_mms");
$conn = sqlsrv_connect( $serverName, $connectionInfo );
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
?>
答案 0 :(得分:0)
修复它以传递另外两个参数(如用户信息)
<?php
//check all parameters
$serverName = "server_name";
$uid = "testuser";
$pwd = "V*****";
$databaseName = "testdb_mms";
//check config
$connectionInfo = array( "UID"=>$uid,
"PWD"=>$pwd,
"Database"=>$databaseName);
$conn = sqlsrv_connect( $serverName, $connectionInfo );
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
?>