MSSQL PHP远程连接

MSSQL PHP远程连接,php,sql-server,mamp,Php,Sql Server,Mamp,更新: 降级到PHP5.5.38-仍然不工作 _ 我正在尝试连接到网络上的远程mssql数据库 我尝试过以下代码: <?php // Server in the this format: <computer>\<instance name> or // <server>,<port> when using a non default port number $server = '192.168.2.254\HQ'; // Connect t

更新:

降级到PHP5.5.38-仍然不工作

_

我正在尝试连接到网络上的远程mssql数据库

我尝试过以下代码:

<?php
// Server in the this format: <computer>\<instance name> or
// <server>,<port> when using a non default port number
$server = '192.168.2.254\HQ';

// Connect to MSSQL
$link = mssql_connect($server, 'username', 'password');

if (!$link) {
    die('Something went wrong while connecting to MSSQL');
}
?>
经过一些研究,我发现这段视频说明我应该下载一些.dll文件并重新启动Apache。

但是,我在mac上使用MAMP在本地运行。有什么想法吗

其他信息:

PHP Version 7.1.1

System  Darwin Andy-iMac.local 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64
Build Date  Jan 23 2017 14:35:48
Configure Command   './configure' '--with-apxs2=/Applications/MAMP/Library/bin/apxs' '--with-gd' '--with-jpeg-dir=/Applications/MAMP/Library' '--with-png-dir=/Applications/MAMP/Library' '--with-zlib' '--with-zlib-dir=/Applications/MAMP/Library' '--with-freetype-dir=/Applications/MAMP/Library' '--prefix=/Applications/MAMP/bin/php/php7.1.1' '--exec-prefix=/Applications/MAMP/bin/php/php7.1.1' '--sysconfdir=/Applications/MAMP/bin/php/php7.1.1/conf' '--with-config-file-path=/Applications/MAMP/bin/php/php7.1.1/conf' '--enable-ftp' '--enable-gd-native-ttf' '--with-bz2=/Applications/MAMP/Library' '--with-ldap' '--with-mysqli=mysqlnd' '--enable-mbstring=all' '--with-curl=/Applications/MAMP/Library' '--enable-sockets' '--enable-bcmath' '--with-imap=shared,/Applications/MAMP/Library/lib/imap-2007f' '--with-imap-ssl=/Applications/MAMP/Library' '--enable-soap' '--with-kerberos' '--enable-calendar' '--with-pgsql=shared,/Applications/MAMP/Library/pg' '--enable-exif' '--with-libxml-dir=/Applications/MAMP/Library' '--with-gettext=shared,/Applications/MAMP/Library' '--with-xsl=/Applications/MAMP/Library' '--with-pdo-mysql=mysqlnd' '--with-pdo-pgsql=shared,/Applications/MAMP/Library/pg' '--with-mcrypt=shared,/Applications/MAMP/Library' '--with-openssl=/Applications/MAMP/Library' '--enable-zip' '--with-iconv=/Applications/MAMP/Library' '--enable-opcache' '--enable-intl' '--with-tidy=shared' '--with-icu-dir=/Applications/MAMP/Library' '--enable-wddx' '--with-libexpat-dir=/Applications/MAMP/Library' '--with-readline' '--with-mhash' 'YACC=/Applications/MAMP/Library/bin/bison'
Server API  Apache 2.0 Handler
Virtual Directory Support   disabled
Configuration File (php.ini) Path   /Applications/MAMP/bin/php/php7.1.1/conf
Loaded Configuration File   /Applications/MAMP/bin/php/php7.1.1/conf/php.ini
Scan this dir for additional .ini files (none)
Additional .ini files parsed    (none)
PHP API 20160303
PHP Extension   20160303
Zend Extension  320160303
Zend Extension Build    API320160303,NTS
PHP Extension Build API20160303,NTS
Debug Build no
Thread Safety   disabled
Zend Signal Handling    enabled
Zend Memory Manager enabled
Zend Multibyte Support  provided by mbstring
IPv6 Support    enabled
DTrace Support  disabled
Registered PHP Streams  https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters   zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*

用mysql替换mssql_connect_connect@user1544541谢谢,伙计,但这是一个MSSQL连接。此外,PHP 5.5.0中不推荐使用mysql_connect。PHP_mssql.dll是否在PHP.ini中启用了此扩展?请检查@user1544541,谢谢。事实上我以前已经看过那一页了。如我在问题中所述,我正在mac上运行MAMP,无法使用.dll文件。请用mysql替换mssql_connect_connect@user1544541谢谢,伙计,但这是一个MSSQL连接。此外,PHP 5.5.0中不推荐使用mysql_connect。PHP_mssql.dll是否在PHP.ini中启用了此扩展?请检查@user1544541,谢谢。事实上我以前已经看过那一页了。如我在问题中所述,我在mac上运行MAMP,无法使用.dll文件。
PHP Version 7.1.1

System  Darwin Andy-iMac.local 16.4.0 Darwin Kernel Version 16.4.0: Thu Dec 22 22:53:21 PST 2016; root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64
Build Date  Jan 23 2017 14:35:48
Configure Command   './configure' '--with-apxs2=/Applications/MAMP/Library/bin/apxs' '--with-gd' '--with-jpeg-dir=/Applications/MAMP/Library' '--with-png-dir=/Applications/MAMP/Library' '--with-zlib' '--with-zlib-dir=/Applications/MAMP/Library' '--with-freetype-dir=/Applications/MAMP/Library' '--prefix=/Applications/MAMP/bin/php/php7.1.1' '--exec-prefix=/Applications/MAMP/bin/php/php7.1.1' '--sysconfdir=/Applications/MAMP/bin/php/php7.1.1/conf' '--with-config-file-path=/Applications/MAMP/bin/php/php7.1.1/conf' '--enable-ftp' '--enable-gd-native-ttf' '--with-bz2=/Applications/MAMP/Library' '--with-ldap' '--with-mysqli=mysqlnd' '--enable-mbstring=all' '--with-curl=/Applications/MAMP/Library' '--enable-sockets' '--enable-bcmath' '--with-imap=shared,/Applications/MAMP/Library/lib/imap-2007f' '--with-imap-ssl=/Applications/MAMP/Library' '--enable-soap' '--with-kerberos' '--enable-calendar' '--with-pgsql=shared,/Applications/MAMP/Library/pg' '--enable-exif' '--with-libxml-dir=/Applications/MAMP/Library' '--with-gettext=shared,/Applications/MAMP/Library' '--with-xsl=/Applications/MAMP/Library' '--with-pdo-mysql=mysqlnd' '--with-pdo-pgsql=shared,/Applications/MAMP/Library/pg' '--with-mcrypt=shared,/Applications/MAMP/Library' '--with-openssl=/Applications/MAMP/Library' '--enable-zip' '--with-iconv=/Applications/MAMP/Library' '--enable-opcache' '--enable-intl' '--with-tidy=shared' '--with-icu-dir=/Applications/MAMP/Library' '--enable-wddx' '--with-libexpat-dir=/Applications/MAMP/Library' '--with-readline' '--with-mhash' 'YACC=/Applications/MAMP/Library/bin/bison'
Server API  Apache 2.0 Handler
Virtual Directory Support   disabled
Configuration File (php.ini) Path   /Applications/MAMP/bin/php/php7.1.1/conf
Loaded Configuration File   /Applications/MAMP/bin/php/php7.1.1/conf/php.ini
Scan this dir for additional .ini files (none)
Additional .ini files parsed    (none)
PHP API 20160303
PHP Extension   20160303
Zend Extension  320160303
Zend Extension Build    API320160303,NTS
PHP Extension Build API20160303,NTS
Debug Build no
Thread Safety   disabled
Zend Signal Handling    enabled
Zend Memory Manager enabled
Zend Multibyte Support  provided by mbstring
IPv6 Support    enabled
DTrace Support  disabled
Registered PHP Streams  https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, zip
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters   zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*