tfburges Posted August 21, 2008 Share Posted August 21, 2008 Suppose there's a server with the IP address 10.20.30.40 containing ODBC with data I'd like to retrieve, and suppose the database is located within the directory "first_dir\second_dir\example\source.rbm." What's the command to connect and reach that source? I've read through php's manual and googled a few different things but I haven't quite found what I need. This is where I am: $conn = odbc_connect('10.20.30.40', $user, $pass); if ($conn <= 0) { echo "Could not connect."; exit; } else { echo "Connection successful."; } I've tried listing the directory after the IP and a few other variations. What's the syntax? I'll keep searching... Quote Link to comment Share on other sites More sharing options...
tfburges Posted August 21, 2008 Author Share Posted August 21, 2008 Another question... why would I want to use a MySQL driver when there are perfectly applicable commands for odbc? Like this: $dsn = "DRIVER={MySQL ODBC 3.51 Driver};" . "CommLinks=tcpip(Host=$db_host);" . "DatabaseName=$db_name;" . "uid=$db_user; pwd=$db_pass"; Why not just stick with ODBC? And when using odbc_connect or odbc_pconnect, do I have to use the same syntax as the code above? Quote Link to comment Share on other sites More sharing options...
tfburges Posted August 21, 2008 Author Share Posted August 21, 2008 I just tried this and no worky... $odbchost = '10.20.30.40'; $odbcuser = 'user'; $odbcpass = 'pass'; $odbcdbname = 'directories\example.rbm'; $dsn = "DRIVER={CSI RBM 4.02 ODBC Driver};" . "CommLinks=tcpip(Host=$odbchost;" . "DatabaseName=$odbcdbname;" . "uid=$odbcuser; pwd=$odbcpass"; $conn = odbc_connect($dsn, $odbcuser, $odbcpass); if ($conn <= 0) { echo "Connection failed."; exit; } else { echo "Connection successful."; } I've also tried changing "CSI RBM 4.02 ODBC Driver" to the actual location of the driver dll. Quote Link to comment Share on other sites More sharing options...
tfburges Posted August 21, 2008 Author Share Posted August 21, 2008 Changed every single slash to double slashes... still not working. Quote Link to comment Share on other sites More sharing options...
tfburges Posted August 21, 2008 Author Share Posted August 21, 2008 No one knows how to do this? Quote Link to comment Share on other sites More sharing options...
mbeals Posted August 21, 2008 Share Posted August 21, 2008 are you sure the user you are logging in with has permissions to log in remotely? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted August 21, 2008 Share Posted August 21, 2008 it doesn't matter where the data is on the remote server. you should only request the actual name of the database, not the path to the database file. $odbcdbname = 'example'; Quote Link to comment Share on other sites More sharing options...
tfburges Posted August 21, 2008 Author Share Posted August 21, 2008 I'm positive. I can query the database through Microsoft Access. I'm getting the following error: Warning: odbc_pconnect() [function.odbc-pconnect]: SQL error: [sYWARE, Inc.][Dr. DeeBee ODBC Driver]Unable to connect, SQL state 08001 in SQLConnect in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\admin\notifications.php on line 20 DRIVER={CSI RBM 4.02 ODBC Driver};CommLinks=tcpip(Host=rbm1;DatabaseName=\\rbm1\rbmnet\RBMsuite\CustData\RbmS\Example.rbm;uid=user; pwd=pass Connection failed. And the code up to that point: $odbc_host = 'rbm1'; $odbc_user = 'user'; $odbc_pass = 'pass'; $odbc_dbname = '\\\\rbm1\\rbmnet\\RBMsuite\\CustData\\RbmS\\Example.rbm'; $odbc_dsn = "DRIVER={CSI RBM 4.02 ODBC Driver};" . "CommLinks=tcpip(Host=$odbc_host;" . "DatabaseName=$odbc_dbname;" . "uid=$odbc_user; pwd=$odbc_pass"; $odbc_connect = odbc_pconnect($odbc_dsn, $odbc_user, $odbc_pass); echo $odbc_dsn,"<br>"; if ($odbc_connect <= 0) { echo "Connection failed."; exit; } else { echo "Connection successful."; } (Sensitive information has of course been replaced.) Quote Link to comment Share on other sites More sharing options...
tfburges Posted August 21, 2008 Author Share Posted August 21, 2008 it doesn't matter where the data is on the remote server. you should only request the actual name of the database, not the path to the database file. $odbcdbname = 'example'; Thanks for the reply. I've tried this but to no avail. I just tried again just to make sure and I'm receiving the same message. $odbc_host = 'rbm1'; $odbc_user = 'user'; $odbc_pass = 'pass'; $odbc_dbname = 'Example.rbm'; $odbc_dsn = "DRIVER={CSI RBM 4.02 ODBC Driver};" . "CommLinks=tcpip(Host=$odbc_host;" . "DatabaseName=$odbc_dbname;" . "uid=$odbc_user; pwd=$odbc_pass"; $odbc_connect = odbc_pconnect($odbc_dsn, $odbc_user, $odbc_pass); echo $odbc_dsn,"<br>"; if ($odbc_connect <= 0) { echo "Connection failed."; exit; } else { echo "Connection successful."; } Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted August 21, 2008 Share Posted August 21, 2008 at first glance, it appears you don't have permission to connect to the server. i don't know why you'd use ODBC when you could just use mysql_ functions. you'd be able to remove a lot of possible problems using only one statement instead of all that ODBC stuff. mysql_connect('10.20.30.40', $user, $pass); // no need for any DSN ODBC stuff. Quote Link to comment Share on other sites More sharing options...
tfburges Posted August 21, 2008 Author Share Posted August 21, 2008 The database isn't mysql. It requires a different driver, i.e. the CSI RBM 4.02 ODBC Driver. I'm trying to contact the RBM guys and see if they can shed any light on the situation. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted August 21, 2008 Share Posted August 21, 2008 it looks like you're using a MySQL ODBC driver here: DRIVER={MySQL ODBC 3.51 Driver}; no? What kind of database are you connecting to? ODBC is not a database, it is a method of connecting to a database. if you're connecting to a MySQL server, i'd use mysql_ commands. if you're NOT connecting to MySQL, you're probably using the wrong ODBC driver. my advice: try to avoid ODBC if at all possible. been there, done that, and it's way more work than it needs to be. Quote Link to comment Share on other sites More sharing options...
tfburges Posted August 21, 2008 Author Share Posted August 21, 2008 That MySQL Driver stuff was some code I pulled off another web site that I was inquiring about. Turns out it's not what I'm looking for anyway. I'm positive that the driver I'm using now is the right one because I'm using the same one to query the database in Access. And I wish I could change the server but I can't without tons of work. The server isn't my doing anyway. All I really need to be able to do is retrieve some data from it through PHP. I hate it when stuff like this happens. It shouldn't be so complicated! Quote Link to comment Share on other sites More sharing options...
tfburges Posted August 21, 2008 Author Share Posted August 21, 2008 Is it possible that the driver simply can't handle queries from php? I've searched all over the place for information on this driver and it is apparently not used anywhere other than where I work LOL. I don't think I've found information on it in more than 3 places and they were of no help whatsoever. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.