Skip to content

Instantly share code, notes, and snippets.

@whaone79
Created January 18, 2016 02:11
Show Gist options
  • Save whaone79/85c48636f3b7437b3aed to your computer and use it in GitHub Desktop.
Save whaone79/85c48636f3b7437b3aed to your computer and use it in GitHub Desktop.
Mengakses SQL Server 2008R2 dari PHP, silahkan lihat di : http://w4w417.wordpress.com/2016/01/08/mengakses-sql-server-2008r2-dari-php/
<?php
echo "Mengakses SQL Server : ";
$serverName = "192.168.0.5\sql2008r2";
$connectionOptions = array('Database'=>'RETAIL', 'UID'=>'sqluser', 'PWD'=>'12345');
$conn = sqlsrv_connect( $serverName, $connectionOptions);
if( $conn === false )
{
echo "Could not connect.\n";
die( print_r( sqlsrv_errors(), true));
}
else {
echo "koneksi berhasil..!";
echo "Data item :";
$tsql = "select ITM_CD,ITM_NAME,PRICE from dbo.RETAIL_ITEM ";
$result = sqlsrv_query($conn, $tsql);
while($row = sqlsrv_fetch_array($result))
{
echo($row['ITM_CD'] . ', '.
$row['ITM_NAME'] . ', '.
$row['PRICE'].'<br>');
}
sqlsrv_close($conn);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment