Hi Professionals
I have installed php successfully i think as I can display a hello world with a php file.
The problem I am encountering is that I am trying to query the SQLServer database and it just gets as far as “Error connecting to SQL Server”
any ideas, here is the code
<?php $serverName = "d3licsql02"; $database = "TestData"; // Get UID and PWD from variables. $uid = "sa"; $pwd = "secret"; echo $serverName; echo ""; echo $database; echo "
"; echo $uid; echo "
"; echo $pwd; echo "
"; try { $conn = new PDO( "sqlsrv:server=$serverName;Database = $database", $uid, $pwd); $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 Postcodes.Suburb'; $stmt = $conn->query( $query ); while ( $row = $stmt->fetch( PDO::FETCH_ASSOC ) ){ print_r( $row ); } // Free statement and connection resources. $stmt = null; $conn = null; ?>