Skip to content

Instantly share code, notes, and snippets.

@ezimuel
Created April 3, 2013 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezimuel/5301941 to your computer and use it in GitHub Desktop.
Save ezimuel/5301941 to your computer and use it in GitHub Desktop.
Db2 connect using ODBC parameters
<?php
$database = '';
$user = '';
$password = '';
$hostname = '';
$port = 446;
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;".
"HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP;UID=$user;PWD=$password;";
$conn = db2_connect($conn_string, '', '');
if ($conn) {
echo "Connection succeeded.\n";
} else {
echo "ERROR: connection failed.\n";
var_dump(db2_conn_errormsg());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment