所以我重新安装了我的网络服务器"。它有一些操作系统问题,我觉得是时候了!我复制/备份了整个WAMP文件夹,并在重新安装后很好地恢复了它。所有这些都有效,而不是它应该的网站。实质上, sqlsrv_connect 似乎没有连接!它没有给我任何错误输出。 $conn = sqlsrv_connect($serverName, $connectionInfo);
即将出现" false "
我的设置:
'''
Windows 7 Enterprise 64 bit SP1
Wamp Version 2.5 (32bit)
Apache Version 2.4.9
PHP Version 5.5.12
MySQL Version 5.6.17
Microsoft SQL Server 2005 (on an external server)
extension=php_pdo_sqlsrv_55_ts.dll
extension=php_sqlsrv_55_ts.dll
'''
PHP在另一台服务器上运行得很好。然而,该服务器使用IIS。
$serverName = "first.second.third.fourth.fifth";
$connectionInfo = array("Database"=>"Databasename", "UID"=>"Username", "PWD"=>"password");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if (!$conn) {echo "no connection to database/server";}
$sql = "SELECT * FROM Tablename";
$results = sqlsrv_query( $conn, $sql ); if($results === false) {print_r( sqlsrv_errors(), true);}
到目前为止我尝试过的事情:
我错过了什么?我真的认为这是一个小地方 - 只是无法弄清楚在哪里或什么!也许它是一个允许这个系统连接到SQL服务器的设置?默认情况下,此设置在IIS服务器上启用...?也许我需要以某种方式传递额外的身份验证?
答案 0 :(得分:0)
首先,我用它来获取错误消息:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Review Sample Month Only</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript">
$(function () {
$('#datetimepicker').datetimepicker({
format: 'MM',
viewMode: 'months'
});
});
</script>
</head>
<body >
<div class="container" >
<div class="panel-group">
<div class="panel panel-primary" >
<div class="panel-heading" >
<h3 class="panel-title" style="text-align: center;">Review Sample Month Only</h3>
</div>
<div class="panel-body">
<form class="form-horizontal" >
<div class="form-group">
<label class="control-label col-sm-2" for="datetimepicker" >Month:</label>
<div class="col-sm-2">
<div class='input-group date'>
<input type='text' class="form-control" id='datetimepicker' name= "datetimepicker" placeholder="MM"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" id="button1" class="btn btn-primary">Save</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
然后问题是它需要我从这里得到的ODBC驱动程序:
https://www.microsoft.com/en-us/download/details.aspx?id=36434
下载64位版本并安装它,一切正常。