我从 sql 查询中提取了几个值(见下文),一切正常,直到我尝试在页面上显示 LastMessageTime(日期/时间)。当我尝试在页面上显示 LastMessageTime 时,页面不会在此之后呈现任何内容或 LastMessageTime 。我直接通过 sql 查询提取了值并得到了这个 2013-03-15 17:32:10.000。我不确定我是否需要逃避某些东西,或者是否缺少其他东西
$sql = "SELECT Name, DNSName, LastMessageTime, IDENumber, Version FROM Computers where Name = '$assetname'";
echo "<table border=1 bordercolor=#FFCC00 style=background-color:#FFFFCC width=100% cellpadding=3 cellspacing=5>";
echo "<tr>";
echo "<td><b>Information</b></td>";
echo "</tr>";
echo "<p style=font-family:verdana,arial,sans-serif;font-size:10px;</p>";
echo "</table>";
echo "<table border =1 width=100% cellpadding=3 cellspacing=5>";
echo "<td> Installed</td>";
echo "<td>".$SAVI2."</td>";
echo "</tr>";
echo "<tr>";
echo "<td> Version</td>";
echo "<td>".$row['Version']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td> IDE Number</td>";
echo "<td>".$row['IDENumber']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td> Last Report time</td>";
echo "<td>".$row['LastMessageTime']."</td>";
echo "</tr>";
echo "</table>";
$vard = $row['LastMessageTime']; 回声 var_dump($vard);
返回页面对象(日期时间)#1 (3) { ["date"]=> string(19) "2013-03-15 16:47:52" ["timezone_type"]=> int(3) ["timezone "]=> 字符串(14) "美国/丹佛" }
$sql = "SELECT Name, DomainName, OperatingSystem, ServicePack, IPAddressText, DNSName, SAVInstalled, LastLoggedOnUser, SAVVersion, IDENumber, SAVOnAccess, LastMessageTime FROM Computers where Name = '$assetname'";
$stmt = sqlsrv_query( $conn, $sql );
// Check for 0 results
if( $stmt === false) {
die( print_r( sqlsrv_errors(), true) );
}
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
echo "<table border=1 bordercolor=#FFCC00 style=background-color:#FFFFCC width=100% cellpadding=3 cellspacing=5>";
echo "<tr>";
echo "<td><b>Information</b></td>";
echo "</tr>";
echo "<p style=font-family:verdana,arial,sans-serif;font-size:10px;</p>";
echo "</table>";
echo "<table border =1 width=100% cellpadding=3 cellspacing=5>";
echo "<td> Installed</td>";
echo "<td>".$SAVI2."</td>";
echo "</tr>";
echo "<tr>";
echo "<td> Version</td>";
echo "<td>".$row['SAVVersion']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td> IDE Number</td>";
echo "<td>".$row['IDENumber']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>last date</td>";
echo "<td>".$row['LastMessageTime']."</td>";
echo "</tr>";
echo "</table>";
$vard = $row['LastMessageTime'];
echo var_dump($vard);
}
/* Close the connection. */
sqlsrv_close( $conn);
?>