在此代码中找不到错误,页面显示为空白


Cant find the mistake in this code, page shows up blank

<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
session_start();
if(!isset($_SESSION['user_id'])){
header('Location: login.php');
exit();
}
include('includes/db_connect.php');
$userid = $_SESSION['user_id'];
$sql = ("SELECT file_id FROM files WHERE user_id='$userid'");
$query = $db->query($sql);
if($query->num_rows ===1){
echo "<a href="index.php">Sorry you have already uploaded a file, to delete the current file and upload another please select retieve file from the homepage</a>";
}else{
echo "you can upload a file";
}
?>

上述检查以查看用户是否已上传文件。它通过查看是否有带有其用户 ID 的文件来实现这一点。 由于某种原因,页面在加载时只是空白。

包括 只持有连接字符串

多年来一直在关注这个,将不胜感激,提前感谢您

此行有语法错误:

echo "<a href="index.php">Sorry you have already uploaded a file, to delete the current file and upload another please select retieve file from the homepage</a>";

如果定义带有双引号 ("( 的字符串,则必须转义字符串中包含的所有双引号。

将其替换为:

echo "<a href='"index.php'">Sorry you have already uploaded a file, to delete the current file and upload another please select retieve file from the homepage</a>";