note 114448 deleted from function.odbc-connect by cmb

From: Date: Sun, 11 Dec 2016 12:20:28 +0000
Subject: note 114448 deleted from function.odbc-connect by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208557@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- I was having trouble connecting to a MSSQL database using FreeTDS and a DSN string with the error message: "Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect" The problem was with specifying the driver. Many examples show the driver name surrounded by { } The solution was to remove the braces. Example: <?php $user = "username"; $pass = "password"; // Some examples show "Driver={FreeTDS};" but this will not work $dsn = "Driver=FreeTDS;Server=some.server.com;Port=1433;Database=mydatabase;"; $cx = odbc_connect($dsn,$user,$pass); // Get the error message if($cx === false) { throw new ErrorExcpetion(odbc_errormsg()); } ?>

« previous php.notes (#208557) next »