phpodbcu2universe

Connect PHP to UniVerse ODBC DSN


I have what seems a simple question, but I just cant get php to connect to my ODBC DSN.

I have a webserver with an ODBC DSN configured properly, I can test the connection and it works just fine.

I am now trying to connect PHP to this DSN.

MYDSNNAME is using the driver: UniVerse 64-Bit ODBC Driver.

Here is my php code:

$conn=odbc_connect('MYDSNNAME','username','password',SQL_CUR_USE_ODBC);

if (!$conn)
{
    exit("Connection Failed: " . $conn);
}

$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);

if (!$rs)
{
    exit("Error in SQL");
}

dbc_close($conn);

I am getting the following error:

Message: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect

I have tried using the 64bit ODBC administrator and that did not work. Any suggestions would be great.

Thanks


Solution

  • I was able to circumvent the error I was getting by using the 32bit version of the driver within my ODBC Administrator and I am now connecting just fine.

    It gets a little tricky with 32/64bit versions of the odbc administrator.