简体   繁体   English

在PHP中连接到Linux上的MS SQL Server

[英]Connecting to MS SQL Server on Linux in php

$server = 'x.x.x.x\SQLEXPRESS'; 
$link = mssql_connect($server, 'username', 'password');


if (!$link)
 {

    die('Something went wrong while connecting to MSSQL');

}
else
{
echo "Connected!";
}

It works on windows operating system. 它适用于Windows操作系统。 but when run linux show "Something went wrong while connecting to MSSQL" please help me 但是当运行linux时显示“连接到MSSQL时出了点问题”,请帮帮我

Be sure to 务必

1.Enable the loading of mssql libraries in php.ini. 1.启用在php.ini中加载mssql库。

2.Check for status of services 2.检查服务状态

3.And also check the php log file to know exactly what is the error. 3.还要检查php日志文件以确切知道错误是什么。

error_reporting(E_ALL);
ini_set('display_errors', true);
flush();

You can add this piece of code in starting of your .php file, and check what is the exact error. 您可以在.php文件的开头添加这段代码,并检查确切的错误是什么。

thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM