Skip to content

Instantly share code, notes, and snippets.

@rohman
Created April 17, 2013 23:17
Show Gist options
  • Save rohman/5408553 to your computer and use it in GitHub Desktop.
Save rohman/5408553 to your computer and use it in GitHub Desktop.
PHP ODBC Connection
<?php
$host = '127.0.0.1'; // ini merupakan hostnya
$db = 'databasenya';
$user = 'sa'; // user sql server
$pwd = 'sa'; // password sql server
//$dsn = "Driver={SQL Native Client};Server=$host;Database=$db; Uid=$user;Pwd=$pwd;";
// This is a more generic one I use with to dev with, Windows 7 and SQL Server 2008
$dsn = "Driver={SQL Server};Server=$host;Database=$db; Uid=$user;Pwd=$pwd;"; // only for dev. purposes
try{
$conn = odbc_connect($dsn, $user, $pwd);
echo "yay sukses";
}catch (Exception $e){
die('Could not connect to database.');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment