I am getting "Fatal error: Invalid handle returned. in" in PHP 7 while trying to connect with SQL Server.
I have already tried below option
Error connecting to MSSQL with SQLSrv and PHP 5.4.7 Unable to connect to SQL Server with PHP
I am using below code:
try {
$conn = new PDO( "sqlsrv:Server=(10.10.10.222\sql2008r2);Database=test",'sa', 'sipl@123');
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}
catch( PDOException $e ) {
die( "Error connecting to SQL Server" );
}
echo "Connected to SQL Server\n";
$query = 'SELECT *FROM atlas_positions';
$stmt = $conn->query( $query );
while ( $row = $stmt->fetch( PDO::FETCH_ASSOC ) ){
echo '<pre>';
print_r( $row );
echo '</pre>';
}
Your views will be beneficial for me.