Created
April 17, 2013 23:17
-
-
Save rohman/5408553 to your computer and use it in GitHub Desktop.
PHP ODBC Connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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