获取错误PHP解析错误:语法错误,第41行的C:\ Inetpub \ vhosts \ mysite.com \ subdomains \ login \ public \ helpdesk \ deleteproduct.php中的意外文件结尾
<?php
// connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
// confirm that the 'id' variable has been set
if (isset($_GET['id']) && is_numeric($_GET['id']))
{
// get the 'id' variable from the URL
$id = $_GET['id'];
// delete record from database
if ($stmt = $mysqli->prepare("DELETE FROM product WHERE id = ? LIMIT 1"))
{
$stmt->bind_param("i",$id);
$stmt->execute();
$stmt->close();
}
else
{
echo "ERROR: could not prepare SQL statement.";
}
$mysqli->close();
// redirect user after delete is successful
header("location:javascript://history.go(-2)");
}
else
// if the 'id' variable isn't set, redirect the user
{
header("location:javascript://history.go(-1)");
}
?>
答案 0 :(得分:0)
添加结束括号:
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}