Using simple PHP script to establish connect to and query SAM_PROD DB the following occurs using the following method:
Note: In both cases I'm using the exact same script file.
- Browser:
- Connection Failed.
- no error messages are produced beyond this.
- I get confirmation of connection failure if I add a "echo "connection failed"; otherwise it's just blank...
- Command Prompt
- Connects and returns results of query successfully.
I've gone through my IIS settings between DEV/PROD and both are, as far as I can tell identical, unless I'm missing something obscure.
Only difference I came across was that in Dev IUSR has read access to PHP folder, I revoked it's rights in Dev, and no issues occured.
*edit* Sorry wanted to include the script used:
<?php
$serverName = "dbNAME";
$user = "user";
$passw = "paSSWORD";
$db_name = "SAM_PROD";
$connInfo = array( "Database"=>"$db_name", "UID"=>"$user", "PWD"=>"$passw");
$conn = sqlsrv_connect( $serverName, $connInfo);
sqlsrv_configure("WarningsReturnAsErrors", 1);
if( $conn === false ){
die(print_r( sqlsrv_errors(), true));
}
$sql = "SELECT * FROM SAM_PROD.DBO.users";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false ) {
if( ($errors = sqlsrv_errors() ) != null) {
foreach( $errors as $error ) {
echo "SQLSTATE: ".$error[ 'SQLSTATE']."<br />";
echo "code: ".$error[ 'code']."<br />";
echo "message: ".$error[ 'message']."<br />";
}
}
}else{
echo "Connection established.\n";
echo "Rows returned: \n";
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
echo $row['login']." , ";
}}
?>