views:

11

answers:

0

My webhost is Pair.com, which runs FreeBSD. PHP is compiled with iODBC. I have SSH2 compiled and installed and tested. I can connect to the Windows machine through the firewall and get a directory listing.

What I need is the incantation to open an Access database file through the SSH connection. (Very low-traffic site, so Access should be sufficient.) Here's what I have so far:

function test_connect($IP, $username, $password, $DSN, $DBusername, $DBpassword)
{
echo "Does ssh2_connect() exist?<br />";
    if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist");
    echo "Function exists<br />";
    // log in
    echo "ssh2_connect()<br />";
    if(!($con = ssh2_connect($IP, 3306))){
        echo "fail: unable to establish connection<br />";
    } else {
        echo "ssh2 connected<br />";
        // try to authenticate
        if(!ssh2_auth_password($con, $username, $password)) {
            echo "fail: unable to authenticate<br />";
        } else {
            // allright, we're in!
            echo "okay: logged in...<br />";
            echo "Opening database<br />";
            // open database
            if (!($db = odbc_connect($DSN, $DBusername, $DBpassword ))) {
                echo "fail: unable to connect to database<br />";
            } else {
                // Just say so for now
                echo "connected to database<br />";
                odbc_close($db);
            }
        }
    }
}

Among the things I'm looking for:

  • I found the port 3306 in some of my searching. Is that the correct port for the ssh2_connect call?
  • I can't find any discussion of the form the $DSN string should take over an SSH connection.

It looks like I can't use the DSN I set up on the Windows machine. That connection of the name to the file appears to be done at the OS level. So, I need to open a DSN-Less connection?

I tried using the Access driver example in the PHP documentation. I put the fully qualified name of the file in the string. But, I don't know how to tell it to look for that file through the SSH connection and onto the Windows machine.

Example: "Driver={Microsoft Access Driver (*.mdb)};Dbq=\"C:/Documents and Settings/Mighty/My Documents/Folder/filename.mdb\""

I'm getting an IM003 error.

How do I find out what drivers are available?

Basically, what I need is an example or a pointer to documentation on how to build the string used in the connect call. Or, how to set up a DSN within my *nix+PHP environment that then points to the database on the Windows box.

Thanks, Drake