我收到以下错误。我正在尝试将数据添加到数据库。
解析错误:语法错误,意外' - >'第16行的localhost \ site \ admin \ add.php中的(T_OBJECT_OPERATOR)
这是我的代码:
<?php
session_start();
include_once('../includes/connection.php');
if (isset($_SESSION['logged_in'])) {
if (isset($_POST['title'], $_POST['content'])) {
$title = $_POST['title'];
$content = nl2br($_POST['content']);
if (empty($title) or empty($content)) {
$error = 'All fields are required!';
} else {
$query = pdo->prepare('INSERT INTO articles (article_title, article_content, article_timestamp) VALUES (?, ?, ?)');
$query->bindValue(1, $title);
$query->bindValue(2, $content);
$query->bindValue(3, $timestamp);
$query->bindValue(4, $image);
$query->bindValue(5, $demo);
$query->execute();
header('Location: index.php');
}
}
} else {
header('Location: index.php')
}
?>
答案 0 :(得分:1)
这是问题
header('Location: index.php');
我没有补充;关闭括号后!