The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ODBC connection error for fetching value from MSsql to MYsql

Discussion in 'Database Discussions' started by dhruvpandit, Feb 7, 2012.

  1. dhruvpandit

    dhruvpandit Member

    Joined:
    Sep 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    here is my problem,


    website hosted on cPanel, owner of site requires information from a remote MS access database which user has username/password and hostname/ip address for.



    I assume I have to install some modules into EasyApache, and therefore enable some access for remote services yes/no ?

    i have mysql db on centos cpanel,
    and want to fetch database values from other server which has MSsql DB.

    now, dont know what to enable in whm and what to do on other (MSsql ) server :(

    my server's IP is whitelisted on other server, but still its not working.



    Any and all suggestion would be gratefuly received.
     
  2. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
  3. dhruvpandit

    dhruvpandit Member

    Joined:
    Sep 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    i have tried that procedure , but still receiving same error
    here is the error
    Code:

    Warning: 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 /home/frendzho/public_html/xyz.co.cc/mssql.php on line 5

    Warning: odbc_exec() expects parameter 1 to be resource, boolean given in /home/frendzho/public_html/xyz.co.cc/mssql.php on line 10
    Error in SQL

    its working fine on my local machine,and my server IP is already whitelisted by remote server.
     
  4. dhruvpandit

    dhruvpandit Member

    Joined:
    Sep 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    can anyone help me about it??
     
    #4 dhruvpandit, Feb 8, 2012
    Last edited: Feb 9, 2012
  5. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Here's another forum where this is discussed:

    How I Connect Ms-access Db With Php Using Odbc? - W3Schools Forum

    I will admit that I know nearly nothing about MSSQL, because it's a Windows-based SQL system. You might want to try asking in the Windows area if they know what you need to do for this type of error. Even though it's a PHP script, there is PHP scripting that occurs over in our Windows area and you might have more people familiar with MSSQL over there.

    The error itself isn't specifically indicating the driver doesn't work, just that you haven't actually selected the right driver.
     
  6. dhruvpandit

    dhruvpandit Member

    Joined:
    Sep 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    i am usign this for local

    $dsn = "Driver={SQL Server};Server=xxx.xxx.xxx.xxx;Database=Partners;";
    $user = 'lskdg';
    $pass = 'fsalkdjg';
    $conn = odbc_connect($dsn, $user, $pass);
    if($conn){
    echo "I got it!.";
    }


    i think there is something wrong in first line i.e. "Driver={SQL Server};
     
  7. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    There probably is, but I doubt most people in the Linux area would know what it happens to be. Will you be posting over in the Windows section?
     
  8. dhruvpandit

    dhruvpandit Member

    Joined:
    Sep 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    ODBC connection error for fetching value from MSsql to MYsql (new error)

    hey,
    the driver error is solved with the help of this topic

    http://forums.cpanel.net/f354/adding-mssql-support-php-66644.html

    but now its giving this error

    Fatal error: Call to undefined function odbc_connect() in /home/frendzho/public_html/xxx.co.cc/mssql.php on line 5


    any solution for this??
     
  9. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    What exactly did you do to fix the error? That topic is a full guide and doesn't specifically address the error you mentioned. If you would be able to provide specifics, that would be greatly appreciated.

    Next, have you installed all the components mentioned in this guide?

    How To: Install mssql extension for php on unix « How to Get it Working

    unixODBC would be used for ODBC.
     
  10. dhruvpandit

    dhruvpandit Member

    Joined:
    Sep 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    i have done this
    Code:
    INSTALLING FREETDS
    
    1-. Download freetds -> www.freetds.org
    2-. tar -zxvf freetds-stable-tgz
    3-. cd freetds-*
    4-. ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld
    
    Note: tdsver=8.0 if you use SQL 2000, tdsver=7.0 if you use SQL 7.0
    
    5-. make
    6-. make install
    7-. /usr/local/freetds/bin/tsql -S <ip of the server> -U <User SQL>
    
    Note: For default User SQL is sa and the it have not password
    For example: /usr/local/freetds/bin/tsql -S 198.168.100.2 -U sa
    
    8-. Add the next text in freetds.conf ( /usr/local/freetds/etc )
    [TDS]
    host = <ip of the Server with Sql>
    port = 1433
    tds version = 8.0
    
    Note: If you use SQL 2000 then tds version = 8.0
    if you use SQL 7.0 then tds version = 7.0
    
    9-. Add the following line in the file /etc/ld.so.conf and run ldconfig -v:
    include /usr/local/freetds/lib
    
    10- Recompile PHP with --with-mssql=/usr/local/freetds flag.
    Create a file called all_php4 or all_php5 in:
    
    /var/cpanel/easy/apache/rawopts/
    
    The file doesnt exist by default, just create it and add the line to the file:
    --with-mssql=/usr/local/freetds
    
    11- Copy entire folder where you uncompress the Freetds in my case was /root to:
    
    /usr/local/freetds
    
    12- Go to /usr/local/freetds/src/tds/.libs/ and copy libtds.a to /usr/local/freetds/lib
    
    I do that, because when im trying Recompile PHP send me this error:
    
    checking for MSSQL support via FreeTDS... yes
    configure: error: Could not find /usr/local/freetds/lib/libtds.a
    
    13- Then go to WHM >> Main >> Software >> Apache Update
    Select: Previously Saved Config (** DEFAULT **)
    and press
    Build Profile Now.
    
    but when building apache it gives this error

    Code:
    checking for Oracle Database OCI8 support... no
    /include/sqlext.h' not found!... configure: error: ODBC header file '/usr
    !! './configure --disable-fileinfo --enable-bcmath --enable-calendar --enable-ftp --enable-gd-native-ttf --enable-libxml --enable-magic-quotes --enable-mbstring --enable-pdo=shared --enable-sockets --enable-zip --prefix=/usr/local --with-apxs2=/usr/local/apache/bin/apxs --with-curl=/opt/curlssl/ --with-freetype-dir=/usr --with-gd --with-imap=/opt/php_with_imap_client/ --with-imap-ssl=/usr --with-jpeg-dir=/usr --with-kerberos --with-libxml-dir=/opt/xml2/ --with-mssql=/usr/local/freetds --with-mysql=/usr --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mysqli=/usr/bin/mysql_config --with-openssl=/usr --with-openssl-dir=/usr --with-pcre-regex=/opt/pcre --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-png- --with-xpm-dir=/usr --with-zlib --with-zlib-dir=/usr' failed with exit code '256' !!
    !! Restoring original working apache !!
    !! Executing '/scripts/initsslhttpd' !!
    !! Restarting 'httpd' ... !!
    !! 'httpd' restart complete. !!
    Building global cache for cpanel...Done
    !! Executing '/scripts/initfpsuexec' !!
    !! Executing '/scripts/initsslhttpd' !!
    !! Executing '/scripts/update_apachectl' !!
    Compiling report...
    
    seems something wrong with /var/cpanel/easy/apache/rawopts/all_php5 file

    it contains
    Code:
    --with-unixODBC=/usr
    --with-mssql=/usr/local/freetds
    
    something is wrong with path of unixODBC in all_php5 file, as per my knowledge.

    thanks
     
  11. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    The linked guide suggests manually compiling in unixODBC support:

    cd /
    wget http://www.unixodbc.org/unixODBC-2.2.12.tar.gz
    tar -xvzf unixODBC-2.2.12.tar.gz
    unixODBC-2.2.12
    ./configure -prefix=/usr/local -enable-gui=no
    make && make install

    Also, if you need OCI8 support, I have a thread where I discuss how to install it:

    http://forums.cpanel.net/f145/oracle-easyapache-140437.html#post1018981

    I believe you likely need to install the other components as well that How To: Install mssql extension for php on unix « How to Get it Working mentions in the order it mentions. If you skip a step, things are unlikely to work.
     
  12. dhruvpandit

    dhruvpandit Member

    Joined:
    Sep 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    i dont need OCI8 ,
    and i have done the same thing as per howtogetitworking , but the phpinfo is not showing "ODBC" section, means something is going wrong when apache is compiling,
    and the error is
    Code:
    /include/sqlext.h' not found!... configure: error: ODBC header file '/usr
    
    so, how to make that sqlext.h file there??

    unixODBC + freeTDS is already installed and configured.
    now the problem is phpinfo is not showing ODBC section :( means its not loaded.
    how to get it loaded with apache?
     
  13. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    I've provided my suggestions to re-follow that guide exactly. I don't have any further suggestions if that is not how it would be handled, since that guide doesn't suggest using all_php5 for compiling unixODBC and it also doesn't suggest using odbc.so to connect.
     
  14. dhruvpandit

    dhruvpandit Member

    Joined:
    Sep 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    i have done the same as that site again,

    but still getting the same error,
    you can see the live page on www.muktacinemas.co.cc/mssql.php

    also here is phpinfo : phpinfo()

    in phpinfo, its not showing ODBC sections, thats why i am asking you what to do to add / enable ODBC,
    i have removed that opt file (all_php5) and recompiled apache, but still its giving error. :(

    if you want root access for checking, i can give it to you also.
     
  15. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    We cannot accept root access via the forums due to the security implications (even from PM). The guide doesn't suggest to try to connect using odbc_connect but to configure the settings in the unixODBC files. I see nowhere in that guide where the type of script you are using would be supported by it.
     
  16. dhruvpandit

    dhruvpandit Member

    Joined:
    Sep 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    exactly thats why i had added some other files.but you got angry on me :rolleyes:

    can you tell me from where i can get it done??
    i am ready to pay for it.
    but its very imp. to get it done
     
  17. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    Admitting my lack of knowledge earlier for MSSQL connection strings and then requesting that a post be made into our Windows area where Windows-based users would have more knowledge doesn't indicate anger as far as I'm aware. It indicates willingness to accept that I don't have expertise in this area and pointing you to the right resources to find that expertise.

    I'll go ahead and let someone who might be more helpful go from here. I certainly apologize if being honest is coming across as being angry.

    If you would like to seek a developer's assistance, you may consider the following services in our catalog:

    http://www.cpanel.net/application-catalog/category/cpanelwhm-developers/
     
  18. dhruvpandit

    dhruvpandit Member

    Joined:
    Sep 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    dont worry mate, chill.

    but cant understand how this link helps me!!
     
  19. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You can purchase support for installing the product at that link. You'd mentioned you would like to pay for someone to do it for you:

    Several of the companies listed at that link will help you install components for a fee.
     
  20. dhruvpandit

    dhruvpandit Member

    Joined:
    Sep 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    someone told me that centos 6.2 has some problem with Database,
    is it true??
     
Loading...

Share This Page