troubleshooting Question

"Data source name not found" trying to connect to DSN - using MySQL and PHP

Avatar of alicia1234
alicia1234Flag for United States of America asked on
14 Comments1 Solution553 ViewsLast Modified:
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?)


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 14 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros