I am trying to create a php file to access a mssql database in my desktop and display the data in this webpage. The Web Server is running linux. I can access the mssql DB using sql or windows authentication, throught SQL managemnet studio from public IP with no problem. But cannot display any data in my page. The port is open and server is configured for remote access.
My question is, do i have to install php and microsoft drivers in my PC to make it work? My PC runs with Vista 32 and i use Microsoft SQL Server 2008 for the DB. Thanks.
MY code is...
<?php
$connectionInfo = array( "UID" => "user", "PWD" => "123456", "Database" => "TestDB" );
$link = sqlsrv_connect( "111.222.333.444", $connectionInfo );
if( $link ) {
echo "Connection established.<br />";
} else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true ) );
}
$sql = "SELECT * FROM table";
$stmt = sqlsrv_query( $link, $sql );
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC ) ) {
echo $row['value']."<br />";
}
if( $stmt === false ) {
die( print_r( sqlsrv_errors(), true));
}
?>