Jump to content

Recommended Posts

Posted

I am trying to connect to a MySql database at heliohost using PHP.

 

There was a post "MySql ODBC Driver" from August 2008 (http://www.helionet.org/index/index.php?showtopic=3471&hl=odbc) with a reply from djbob (http://www.helionet.org/index/index.php?showtopic=3471&pid=38289&mode=threaded&start=#entry38289), but it doesn't seem to work now!

 

Here are the connection strings I have tried:

$conn = odbc_connect("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myUserName_myDBName;User=myDBUsername;Password=myDBPassword;Option

=3;", "myDBUsername", "myDBPassword");

$conn = odbc_connect("DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;Database=myUserName_myDBName;User=myDBUsername;Password=myDBPassword;Option

=3;", "myDBUsername", "myDBPassword");

$conn = odbc_connect("Driver={MySQL Driver};Server=localhost;Database=myUserName_myDBName;User=myDBUsername;Password=myDBPassword;Option

=3;", "myDBUsername", "myDBPassword");

$conn = odbc_connect("Driver={MySQL ODBC 3.51 Driver};CommLinks=tcpip(Host=localhost);DatabaseName=myUserName_myDBName;uid=myDBUsername;pwd=myDBPa

ssword", "myDBUsername", "myDBPassword");

 

I always get error "odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect".

 

Has the ODBC driver changed since August 2008?

 

Please Help!

Guest Geoff
Posted

Why not just use mysql_connect()? Have you used MySQL before?

Posted
Why not just use mysql_connect()? Have you used MySQL before?

 

I'd like to keep my PHP code database-agnostic -- I'm tring to deploy my code in different hosting sites (I do just a SELECT and a few APPENDs in my code) so I thought that odbc_connect() was a good option -- do you have a ODBC connection string that works on a MySql/SqlLite databse on Heliohost?

 

Thanks

 

Edward Clements

Guest Geoff
Posted

You're using the wrong solution for this. You should instead look into a database abstraction layer like PDO or Doctrine DBAL.

 

However, I am going to go ahead and escalate this because it looks like you are insistent on using ODBC.

 

@djbob Please see http://www.webaj.com/how-setup-mysql-dsn-d...ommand-line.htm

 

Escalating Request...

Posted

Geoff, thanks for escalating the request -- this PHP web-site is simple and straight forward, I just need it to be DB-agnostic (it just does a couple of SELECTs and INSERTs), a database abstraction layer would be overkill...

 

Edward

Posted
Okay, can you try again now?

 

Sorry, but neither of the four connections in my initial posting work, I still get error

odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in scriptname.php on line nn

mysql_connect() and mysql_select_db() using the same dbname/username/password works ok.

Could it be that I have to use a different (variant of) connection string?

Posted

Sorry, I should've mentioned that it's version 5.1.8 now. So maybe have the DRIVER as {MySQL ODBC 5.1.8 Driver}?

Posted
Sorry, I should've mentioned that it's version 5.1.8 now. So maybe have the DRIVER as {MySQL ODBC 5.1.8 Driver}?

 

All of the following connection strings give the same error "odbc_connect() [function.odbc-connect]: SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect":

 

  1. $conn = odbc_connect("Driver={MySQL ODBC 5.1.8 Driver};Server=localhost;Database=myUserName_myDBName;User=myDBUsername;Password=myDBPassword;Option

    =3;", "myDBUsername", "myDBPassword");

  2. $conn = odbc_connect("DRIVER={MySQL ODBC 5.1.8 Driver};Server=localhost;Database=myUserName_myDBName;User=myDBUsername;Password=myDBPassword;Option

    =3;", "myDBUsername", "myDBPassword");

  3. $conn = odbc_connect("Driver={MySQL Driver};Server=localhost;Database=myUserName_myDBName;User=myDBUsername;Password=myDBPassword;Option

    =3;", "myDBUsername", "myDBPassword");

  4. $conn = odbc_connect("Driver={MySQL ODBC 5.1.8 Driver};CommLinks=tcpip(Host=localhost);DatabaseName=myUserName_myDBName;uid=myDBUsername;pwd=myDBPa

    ssword", "myDBUsername", "myDBPassword");

 

Do I need to change anything else in my connection string(s)?

 

Posted

Honestly, I'm not sure. I can tell you that I installed the MySQL ODBC Connector 5.1.8, but besides that I'm not sure what else needs to be done. Have you tried Googling around for what the valid connection string is? If you have and it isn't working, is there any documentation suggesting that I need to do something more than install ODBC and the MySQL ODBC Connector?

Posted

Closing due to inactivity. PM me to reopen! If I'm unresponsive, just open a new support thread and an admin can reopen this thread for you.

Guest
This topic is now closed to further replies.
×
×
  • Create New...