PHP的SQL服务器连接失败

时间:2018-08-15 06:17:42

标签: php sql-server

$conn =  sqlsrv_connect( "192.168.1.6", 
                          array('Database' =>"epromis_test", 
                                "UID"=>"php_test",
                                "PWD"=>"phptest@123") );
if   ($conn)     
{
    echo   "sucess";
} 
else     
{
    echo    "failed";
}

为什么我无法连接数据库?

预先感谢

1 个答案:

答案 0 :(得分:1)

这里是非常好的php文档http://php.net/manual/en/function.sqlsrv-connect.php的链接。我认为您需要在密码中转义@符号。 @变成&commat。有关如何传递特殊字符https://brajeshwar.github.io/entities/

的链接
<script>
const isString =    (value) => (typeof value === 'string' || value instanceof String);
const isNumber =    (value) => (typeof value === 'number' && isFinite(value));
const isArray =     (value) => (Array.isArray(value));
const isFunction =  (value) => (typeof value === 'function');
const isNull =      (value) => (value === null);
const isUndefined = (value) => (typeof value === 'undefined');
const isBoolean =   (value) => (typeof value === 'boolean');
const isDate =      (value) => (value instanceof Date);
const isRegExp =    (value) => (value && typeof value === 'object' && value.constructor === RegExp);
const isError =     (value) => (value instanceof Error && typeof value.message !== 'undefined');
const isSymbol =    (value) => (typeof value === 'symbol');
const isPlainSybol =(value) => value ? value.constructor === {}.constructor : false;
</script>