我正在学习 PHP,目前正在尝试使用 PHP 打印 MYSQL 表的内容。我不断收到以下错误。
解析错误:语法错误,第 53 行 C:\xampp\htdocs\login2.php 中的文件意外结束
第 53 行是</html>
标签。
这是我的代码:
<html>
<head>
</head>
<body>
<?php
$userName = $_POST["userName"];
$password = $_POST["passwd"];
$firstName = $_POST["firstName"];
$lastName = $_POST["lastName"];
$db_host = "localhost";
$db_username = "root";
$db_name = "labdb";
$con=@mysqli_connect("localhost","root","","labdb");
if(mysqli_connect_errno())
{
echo "Failed MySQL connect" . mysqli_connect_error();
}
$sql="INSERT INTO user (username, password, firstName, lastName)
VALUES
('$_POST[userName]','$_POST[passwd]','$_POST[firstName]','$_POST[lastName]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
$query="SELECT * FROM user";
$result=mysql_query($query);
while($row = mysql_fetch_array($result)){
echo $row['userID'] . " " .$row['username'] . " " . $row['password'] . " " .
$row['firstName'] . " " . $row['lastName'];
echo "<BR/>";
mysqli_close($con);
?>
</body>
</html>
有人可以帮忙吗?