I have lots of experience using MySQL and DSN's with ColdFusion but this is my first attempt to do it with PHP. In ColdFusion, I created the datasource using the ColdFusion MX administrator. I wasn't sure how to do it for PHP, so I relied upon Dreamweaver 8. In Dreamweaver, I created a MySQL Connection called "connWidgets" and it tested successfully.
In PHP, if I connect to my database directly, like this:
$connection = mysql_connect("localhost", "root", "mypassword");
it works fine. I can issue queries and get stuff out of the database.
But when I try to connect using the DSN, with this statement:
$connection = odbc_connect("connWidgets","root","mypassword");
I get this error:
Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\Inetpub\wwwroot\meatormotion\php_sandbox\db_DSN.php on line 3
My development environment is Windows XP SP3 and I'm running IIS as my webserver.
If I go to the Control Panel > Administrative Tools > Data Sources (ODBC)
and look on the System DSN and File DSN tabs, there is nothing there. (I don't know if that matters or not?)