I have only ever used MySQL with PHP but have been asked by a cleint if I would be able to develop a website and import data from an existing database that is updated by bespoke software that they have purchased and runs on their desktop machines (but the database is on a remote server).

I guess what I am asking is how easy is it to use a Microsoft SQL database using PHP compared to MySQL?

Thanks for your help!!

    fairly simple, here is some example code:

    $sqlServer = 'SQL.sqlsvr.net';
    $sqlUser = 'ADMIN';
    $sqlPass = 'pwd';
    $db = 'attaincms';
    // Make SQL server connection
    $s = mssql_connect($sqlServer, $sqlUser, $sqlPass) or die ("Couldn't connect to SQL Server on $sqlServer");
    // Open Databse
    $d = mssql_select_db($db, $s) or die ("Couldn't open database $db");

    $query = 'SELECT * FROM Account WHERE Login = \'' . $username . '\'';
    // Store values in an array.
    $result = mssql_query($query);
    // Store # of rows
    $numRows = mssql_num_rows($result);

    echo '<h1>' . $numRows . ' Row' . ($numRows == 1 ? '' : 's') . ' Returned </h1>';
    while($row = mssql_fetch_array($result))
    {
    echo '<li>' . $row['Password'] . '</li>';
    }

    you need to make sure that the linux server has the proper libraries etc installed, there is a .dll file that needs to be on there as well... check out http://us3.php.net/manual/en/ref.mssql.php for complete list of requirements.

    cheers,
    :xbones: :xbones: :xbones: :xbones:

      Thanks for that - doesn't seem too bad. I don't have control over my server - will the libraries be on there usually? I'll check the php.ini I guess.

      Cheers.

        some servers do provide these lib's, but not usually, it isn't to bad to install them yourself... which reminds me ... if you are using apache on a windows box, you will need to change the php.ini file as well... uncomment the appropriate .dll file and restart apache... should have the file already with php

        cheers
        :mad: :xbones: :quiet:

          Write a Reply...