Bob Bob - 3 months ago 41
PHP Question

WAMP php ODBC Connection 'Warning'

I have a problem with ODBC in php (WAMP Server 2.5, PHP 5.5.12).

When I try to run:

$conn = odbc_connect("odbc_dsn", "user", "pwd");

if ($conn)
echo "Connection established.";
exit("Connection could not be established.");

I get a Warning:

Warning: odbc_connect(): in C:\wamp\www\Concepts\index.php on line 29

Connection could not be established.

If I change the "odbc_dsn" to something else (that doesn't exist) like "fdbasdf" then I get:

Warning: odbc_connect(): SQL error: [Microsoft][ODBC Driver Manager]
Der Datenquellenname wurde nicht gefunden, und es wurde kein Standardtreiber angegeben,
SQL state IM002 in SQLConnect in C:\wamp\www\Concepts\index.php on line

Connection could not be established.


The Data Source could not be found, and no default driver is given.

This tells me that the first execution was able to find the db, but did not open it... Why?

Is this another config thing? Is it trying to execute Client-Side? What can I do?

Bob Bob

You have to specify the Host and Connect protocol:

$connect_string =  "Driver={SQL Anywhere 12};".

// Connect to DB

$conn = odbc_connect( $connect_string, $db_user, $db_pass );