Hello,

Any assistance on this issue would be appreciated. I'm trying to get PHP to connect/Query a Sybase database on a remote server. I have FreeTDS installed properly (I hope) and a small PHP connect page to test that it works. When I try to get a connection ID this is the error returned:

Warning: mssql_connect() [function.mssql-connect]: message: ASA Error -75: Request to start/stop database denied (severity 14)in /usr/local/apache2/htdocs/inv/cisco.php on line 2

This is the code for the page (note: "snipped" means removed for security purposes):

<?php
$link = mssql_connect('CiscoWorks', 'snipped', 'snipped')
or die("Could not connect !");
echo "Connected successfully";
//mssql_close($link);
?>

This is the freetds.conf entry:

[CiscoWorks]
host = snipped
port = 43442
tds version = 5.0

Please note that when I try to connect using the same authentication information from my Win2K laptop using the SQL Anywhere 9 Interactive SQL client, I am able to connect successfully.

Any suggestions? I will gladly provide additional config information if that would help.

Thanks

    Well, I don't understand why you're using mssql_xxx type of functions, which are for Microsoft SQL Server, when you say you're trying to connect to a Sybase server!

    This is the PHP manual page on Sybase functions:
    http://us3.php.net/manual/en/ref.sybase.php

    hth.

      toplay wrote:

      Well, I don't understand why you're using mssql_xxx type of functions, which are for Microsoft SQL Server, when you say you're trying to connect to a Sybase server!

      This is the PHP manual page on Sybase functions:
      http://us3.php.net/manual/en/ref.sybase.php

      hth.

      I also have MSSql support installed for connecting to another server running MS SQL 2000. That connection works just fine. According to all the freetds and php documentation I've found so far, the mssql_xxx functions will work the for MS SQL and Sybase equally.

      If I'm wrong on this, let me know what I need to change. Thanks.

        Gabe wrote:

        ...According to all the freetds and php documentation I've found so far, the mssql_xxx functions will work the for MS SQL and Sybase equally...

        I don't know about that. Ask yourself, then why would PHP have a whole set of commands just for Sybase?

        Why don't you try those Sybase functions and see for yourself.

        Good luck.

          toplay wrote:

          I don't know about that. Ask yourself, then why would PHP have a whole set of commands just for Sybase?

          Why don't you try those Sybase functions and see for yourself.

          Good luck.

          From php.net (admittedly this is a function comment):

          link: http://us2.php.net/sybase

          "Up to php 5.0.4 you cannot install both sybase and mssql (they use the same function names). It turns out though that if you use the Freetds library you can connect to sybase using the mssql functions (and visa versa I assume). Setup your servers in the freetds.conf file (for sybase use specify version 5.0, for mssql 7 or 8.0) and call the database connection as you would with mssql (mssql_conect). You should be able to connect either sql server or sybase. I don't know if all sybase functions will work as expected but basic querying is succesful. Hope this helps someone."

          If this comment is completely false, I'm open to any suggestions

            toplay wrote:

            Well, might as well read other user comments:

            http://us3.php.net/manual/en/function.sybase-connect.php#50978

            .

            Aaahhhh! I figured out the problem. In my specific setup, I'm accessing a SQL Anywhere server using FreeTDS. I failed to notice (my bad) on the documentation for the freeteds.conf file at the very bottom it says the [dataserver] must be the same name of the database if you're connecting to SQL Anywhere. Made the change and the connection worked.

            Hope this helps somebody.

              Write a Reply...