php - 将文件移动到不同文件夹后出现未定义的偏移错误
问题描述
好的,所以我有一个看起来像这样的文件夹..
loginsystem/
homepages/
home14.php
includes/
dbh.inc.php
header.php
index.php
...当用户在我的网站上创建新帐户时,他们会获得一个个人主页(例如 homepages/home14)。我想在 home14.php 文件中包含我用于 index.php 文件的标头。当我尝试重新路由 home14.php 所需的位置时,我得到未定义的偏移错误。错误表明问题出在 header.php 文件的第 29 和 30 行,但它对 index.php 工作得非常好。
当我链接到 home14.php 文件中的标题时,我输入了(需要“../header.php”;)
头文件.php
<?php
require 'includes/dbh.inc.php';
session_start();
date_default_timezone_set('America/Chicago');
include 'includes/comments.inc.php';
?>
<!DOCTYPE html>
<html>
<head>
</head>
<div id="headerContainer">
<!-- If the user is logged in, set username and profile picture.-->
<?php
if (isset($_SESSION['userID'])) {
$id = $_SESSION['userID'];
$sqlImg = "SELECT * FROM profileimg WHERE userid='$id'";
$resultImg = mysqli_query($conn, $sqlImg);
while ($rowImg = mysqli_fetch_assoc($resultImg)) {
if ($rowImg['status'] == 0) {
$filename = "profilepics/profile".$id."*";
$fileinfo = glob($filename);
-------- LINE 29 --- $fileext = explode(".", $fileinfo[0]);
-------- LINE 30 --- $fileactualext = $fileext[1];
echo "<div class=userPicture><img src='profilepics/profile".$id.".".$fileactualext."?".mt_rand()."'></div>";
}
else {
echo "<div class='userPicture'><img src='profilepics/noUser.png'></div>";
}
}
home14.php
<?php
require "../header.php";
if (isset($_SESSION['userID'])) {
echo
"<div class='homeBody'>
</div>";
require "../footer.php";
}
else {
header("Location: ../signup.php");
exit();
}
?>
同样,我想要的只是在 index.php 文件中使用的相同标头,以便在 home14.php 文件中使用。当我在 home14.php 中需要它时,我只得到未定义的偏移量,而不是当我将它与 index.php 一起使用时
解决方案
推荐阅读
- python - 包含dict(a,b,c作为键)的python排序列表
- python - Anaconda 不会运行
- python - 有人可以帮助我如何从这张大图片中自动提取图像吗?
- azure - 重命名 MS Teams 对话机器人 - 应用注册更新
- c# - 在没有 FromCurrentSynchronizationContext 的情况下等待?
- azure - 在没有 SAS 的情况下将文件上传到存储帐户
- flutter - 颤振飞镖上对象的参数值
- python - 导入 pyshark 模块时遇到问题
- regex - 如何在bigquery中获取以某个字符开头的所有单词
- web-scraping - 网络抓取:使用 cookie 发出 POST 请求