note 114448 added to function.odbc-connect

From: Date: Fri, 21 Feb 2014 16:33:10 +0000
Subject: note 114448 added to function.odbc-connect
Groups: php.notes 
Request: Send a blank email to php-notes+get-198584@lists.php.net to get a copy of this message
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()); } ?> ---- Server IP: 216.235.13.26 Probable Submitter: 205.211.133.128 ---- Manual Page -- http://php.net/manual/en/function.odbc-connect.php Edit -- https://master.php.net/note/edit/114448 Del: integrated -- https://master.php.net/note/delete/114448/integrated Del: useless -- https://master.php.net/note/delete/114448/useless Del: bad code -- https://master.php.net/note/delete/114448/bad+code Del: spam -- https://master.php.net/note/delete/114448/spam Del: non-english -- https://master.php.net/note/delete/114448/non-english Del: in docs -- https://master.php.net/note/delete/114448/in+docs Del: other reasons-- https://master.php.net/note/delete/114448 Reject -- https://master.php.net/note/reject/114448 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198584) next »