Me = superBeginner
MyActivity = testing communication between php and my sql database hosted on Azure.(1st time)
MyQuestion = $title
HTMLOutputDesired: web page screenshot showing what I'm looking for
HTMLCurrentOutput: web page screenshot showing what I'm getting
My code:
<!DOCTYPE html>
<html>
<head>
<title>test connection</title>
</head>
<body>
<?php
$serverName = "lunch.database.windows.net";
$connectionInfo = array( "Database"=>"LunchProgramBE", "UID"=>"lunch",
"PWD"=>"*****");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$sql = "Select * from Meals";
$query = sqlsrv_query($conn, $sql);
if( $query === false) {
die( print_r( sqlsrv_errors(), true) );
}
while($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_NUMERIC)){
echo $row[0] . ", " . $row[1] . "<br>";
}
sqlsrv_free_stmt($query);
sqlsrv_close( $conn );
?>
</body>
</html>
If I add this line before the while statement, it works properly... (?)
echo "<br>";
When inspecting the page using chrome, I see that php is adding a pre tag to the end of the html file. This pre tag holds the last item in the list. WHY???
<pre>1, Turkey, V8</pre>
HTML output for bad case: bad case HTML
HTML output for good case: good case HTML
答案 0 :(得分:0)
好吧,如果您没有发送<pre>
标记,我们可以通过查看源代码来判断,那么我能想到的唯一解释是:
<pre>
元素放在那里。前者似乎不太可能,因为您已将源代码更改为有效的HTML并且您仍然看到问题。
正如您现在发现问题在隐身模式中消失,默认情况下会停用扩展程序,因此您的某个Chrome扩展程序很可能因某种原因实际添加了<pre>
标记。通过他们,直到你找到罪魁祸首,你可能能够找出原因......