faqts : Computers : Programming : Languages : PHP : Database Backed Sites : ODBC

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

35 of 74 people (47%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

What causes the ODBC error 'Data source name not found and no default driver specified'?

May 9th, 2000 18:53
Jim Pringle, Nathan Wallace, Andrew Hill


The error you are getting is due to the ODBC driver manager on your
operating system looking for a specific DSN in your code to pass
communication through.  You can either create a DSN in your ODBC control
panel that points to the MySql database, or you can tweak your code and
replace the odbc calls with specific MySql calls, e.g. something like
this:
  $id=@mysql_pconnect($host, $user, $password);
I would recommend creating a DSN, though - that's the whole point of
ODBC; you get database-agnosticism as far as your apps are concerned,
and can switch databases fairly easily if, say, you generate too much
traffic for MySql, or you wish to play with transaction control in that
script.
Another Possible Solution:
I learned odbc from "PHP Essentials" and it suggested using the 
following to connect to ODBC:
     odbc_connect("DSN=PHP","Login","Password") or die ...
This line kept returning the same error you experienced. I removed the 
DSN from "DSN=PHP", it solved my problem. So it looked like:
     odbc_connect("PHP","Login","Password") or die ...
And that did it.  FYI I'm using a Windows 98 with PHP3. Good luck.