【发布时间】:2015-04-22 21:31:53
【问题描述】:
我需要一些帮助来查找此代码的问题。第 20 行就在 $row 评论下方。我已经和其他人一起查看了这段代码,但我们不知道该怎么做。该代码应该最终显示三个值,并且由于此错误,我无法测试该代码。我在第 20 行添加了注释,以便于查找。
<?php
$servername = "localhost";
$username = "dwilson2_410wrt";
$password = "3275626s";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT name, id, comment FROM review";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["name"]. " " $row["comment"]
} // this is line 20
}
$conn->close();
?>
<!DOCTYPE html>
<html>
<head>
<title>My Gaming Products Site</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
有人知道代码有什么问题吗?我知道它一定遗漏了什么,但我不知道是什么。就像我之前说的,第 20 行有一个注释,以便于查找。如果我需要添加更多代码,我会尝试这样做。
【问题讨论】:
-
语法错误离题
-
提示,它不在第 20 行。不要相信 PHP 所说的一切
-
提示:还不到一个完整的。
-
实际的错误安德鲁,我可以叫你安德鲁,是
}之前的那行 -
机器错误 - 第 20 行。人为错误 - 第 19 行
标签: php parse-error