PHP and MSSQL

Discussion in 'PHP' started by Kalyse, Feb 21, 2007.

  1. #1
    I need to connect to a MSSQL database from a Linux CentOS server with Plesk installed.

    I have tried to use the code but I get this:
    Fatal error: Call to undefined function: mssql_connect() in /var/www/vhosts/*****.com/httpdocs/register/load/functions.php on line 65

    Im running version 4.3.9 of PHP.

    Why is it doing this?
     
    Kalyse, Feb 21, 2007 IP
  2. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #2
    noppid, Feb 21, 2007 IP
  3. Kalyse

    Kalyse Peon

    Messages:
    1,221
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey, thanks for that.

    Ihave been reading it for the past 30 minutes.

    I think my main problem is I am running Plesk also.

    I am not sure what damage I will do if I recompile PHP.

    Do you know if Im likely to mess things up?
     
    Kalyse, Feb 21, 2007 IP
  4. -NB-

    -NB- Peon

    Messages:
    153
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Another thing you should look into - make sure your server's PHP configurations have MSSQL on ;)
     
    -NB-, Feb 21, 2007 IP
  5. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #5
    You are actually in an entirely different mess of problems. Plesk has nothing to do with it.

    I am in the final stage of integrating a Fedora 5 Linux server with a MSSQL database on a Windows server.

    Here's the problem.
    MSSQL is a windows program. Even though SQL is a universal language, MSSQL is not a universal platform.

    Linux and php do not inherently have the ability to integrate with MSSQL. All of the mssql_connect and other functions are exclusive to windows machines running php. There are back-end hacks that can setup linux php with the mssql libraries, but these aren't supported by anything solid that I have found.

    Here's where it gets ugly, this is what you need to do to get php integrated with mssql. This is a very complicated setup, and everything needs to be done through the command line.

    First off, you need to make sure that your server and php have odbc support.

    Linux needs a driver called freetds. http://www.freetds.org/

    Linuc also needs to have a library called unixodbc. http://www.unixodbc.org/

    Either of these can be installed with rpm, yum, or command line compiling. Once you are able to connect to the database via linux command line: tsql and isql, you then should be able to connect with php using odbc_connect (not mssql_connect).

    You also need to make sure php is compiled with php-odbc, otherwise it has no way of connecting with the odbc driver.

    Here are some links as to how to get this setup.
    http://www.webthatworks.it/drupal/2006/11/db/odbc_freetds_and_microsoft_sql_and_php
    http://www.linuxjournal.com/article/6636

    I have been working on this one for several weeks, and it is by no means an easy process. If you don't have a lot of linux administration experience, i recommend having someone who does figure it out.

    Anyway, I don't mean to try to scare you out of this, but I was in the same position about a month ago when I though all I needed to do was recompile php. I never realized it was this difficult to get linux php to talk to a windows mssql server.
     
    jestep, Feb 22, 2007 IP