간단한 앱을 개발하겠습니다. 내 응용 프로그램은 PHP 웹 서비스의 도움으로 실제 데이터베이스와 통신합니다. 로컬로 내 애플 리케이션을 테스트하는 동안 모든 것이 잘 작동했다. 나는이를 실행 한 후 내가 서버를 살고 이동하지만하지 (내 데이터베이스 및 웹 서비스 파일이 라이브 서버 ((예)에서 GoDaddy)에서 호스팅됩니다.라이브 SQL 데이터베이스를 Android 앱에 연결하는 방법
<?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 관리 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));
}
?>
를 전달합니다. 귀하의 연결은 db_config.php에 연결되어있는 코드 외부에서 수행됩니다. –
응답 @JamesZ에 감사드립니다. db_config 파일을 첨부했습니다. 게시물에서 나는 그것을 놓쳤습니다. 그렇다면 어떤 인증을 사용할 것인가? – AndroidBoy
SQL Server 인증을 사용하려면 별도의 사용자/로그인을 만들어야합니다. –