Working with a MSSQL DB and a MySQL DB

江枫思渺然 提交于 2019-12-13 04:05:56

问题


I am working on a PHP script in a server. I have two databases:

  1. The first one is a MySQL DB and it is already imported to my server, so it is connected successfully.
  2. The second one is a MSSQL DB and I would like to import it from another server to mine.

The problem is that I don't if I can install MSSQL somehow to the server and I haven't found any solution while searching for it or if I should connect to the two servers simultaneously. Could you maybe help me with that? What is the best solution?

I hope it is not that simple question, but I am a bit new in server administration.


回答1:


Your PHP installation doesn't have MsSQl Extension available. Install MSSQL extension for PHP and it will work. Usually you just have to open a line in php.ini and make sure that mssql module is there in extension folder. restart web server and it will work




回答2:


It seems you didn't enable the MSSQL extension in php.ini file.

In Linux

  • You will find this in php.ini file : ;extension=mssql.so and replace with this : extension=mssql.so( just remove the semicolon to enable.)

  • You will find a file in (if you are using xampp linux) lampp/etc/freetds.conf file. In this file you need to add the following configuration.

    add this:

    [DevSqlServer]

    host = 172.16.1.123

    instance = DEVAPSERVER

    port = 1433

    tds version = 7.0

  • Restart your server. and your php code should be like this.

  • Here you can see what i have done. DevSqlSerrver i have given in the freetds.cof. So i need to give the server name that what i have given in freetds.conf.

      // Connect to MSSQL
       $connection = mssql_connect("DevSqlServer", 'sa', '****');
       $db_connect=mssql_select_db("DBname",$connection);
    

And you can access MSSQL Server database.

For more info:

Link1

Link2



来源:https://stackoverflow.com/questions/16963282/working-with-a-mssql-db-and-a-mysql-db

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!