簡體   English   中英

為什么在網站特定頁面上出現錯誤:瀏覽到index1.php文件時內部服務器錯誤?

[英]Why i'm getting error on the web site specific page: Internal Server Error when browsing to index1.php file ?

我在index1.php中有此代碼,並且我將ifle上載到了我的網站托管網站ipage.com上,並保存到了filemanager。

我將其上傳到根目錄的文件,在根目錄下有一個目錄:files,內部有一個目錄:radar-simulation-files

如果我瀏覽到我的網站主頁,那很好,沒有服務器錯誤消息:

主頁

但是,當我瀏覽到index1.php頁面時,出現錯誤:

index1.php

錯誤消息是:

內部服務器錯誤

服務器遇到內部錯誤或配置錯誤,無法完成您的請求。

請與服務器管理員聯系,並告知他們錯誤發生的時間以及您可能做的任何可能導致錯誤的事情。

服務器錯誤日志中可能會提供有關此錯誤的更多信息。

在此頁面上,我確實右鍵單擊了鼠標和Inspect元素,並且ii看到一個紅色的錯誤:無法加載資源:服務器的狀態為500(內部服務器錯誤)

但是沒有更多有關該錯誤以及導致錯誤的原因的詳細信息。 我想index1.php中的代碼有問題

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
    xmlns="http://www.w3.org/1999/xhtml"
    lang="en"
    xml:lang="en"
><head>

<meta
    http-equiv="Content-Type"
    content="text/html; charset=utf-8"
/>

<meta
    http-equiv="Content-Language"
    content="en"
/>

<meta
    name="viewport"
    content="width=device-width; height=device-height; initial-scale=1.0"
/>

<link
    type="text/css"
    rel="stylesheet"
    href="screen.css"
    media="screen,projection,tv"
/>

<title>
    change picture
</title>

</head><body>

<div id="slideCounter"></div>
<div id="slideShow">
<?php

$allowed_types = ['png','jpg','jpeg','gif'];
$imageDir = 'files/radar-simulation-files';
/*
    Assumes this .php is being run from the http root on the same
    domain as the desired image files.
*/

$handle = opendir($imageDir);
while (($imgPath = readdir($handle)) !== false) if (
    in_array(
        strtolower(pathinfo($imgPath, PATHINFO_EXTENSION)),
        $allowed_types
    )) echo '
    <img src="', $imageDir, '/', $imagePath, '" alt="slide" />';
closedir($handle);

?>
<!-- #slideShow --></div>

<script type="text/javascript">(function(d) {

    // user defines

    var
        swapHours = 0,
        swapMinutes = 0,
        swapSeconds = 5,
        swapTotal = (swapHours * 60 + swapMinutes) * 60 + swapSeconds,
        loopSlideShow = true;

    // some handy helper functions

    function classExists(e, className) {
        return RegExp('(\\s|^)' + className + '(\\s|$)').test(e.className);
    }

    function classAdd(e, className) {
        if (classExists(e, className))
        e.className += (e.className ? ' ' : '') + className;
        return true;
    }

    function classRemove(e, className) {
        if (!classExists(e, className)) return false;
        e.className = e.className.replace(
            new RegExp('(\\s|^)' + n + '(\\s|$)'), ' '
        ) . replace(/^\s+|\s+$/g,'');
        return true;
    }

    function textReplace(e, newtext) {
        if (d.innerText) e.innerText = newText;
            else e.textContent = newText;
    }

    function nodeFirst(e) {
        e = e.firstChild;
        while (e && e.nodeType != 1) e = e.nextSibling;
        return e;
    }

    function nodeLast(e) {
        e = e.lastChild;
        while (e && e.nodeType != 1) e = e.prevSibling;
        return e;
    }

    function nodeNext(e) {
        while (e) if ((e = e.nextSibling).nodeType == 1) return e;
        return null;
    }

    function nodePrev(e) {
        while (e) if ((e = e.prevSibling).nodeType == 1) return e;
        return null;
    }

    // slideShow setup

    var
        slideShow = d.getElementById('slideShow'),
        slideCounter = d.getElementById('slideCounter'),
        firstSlide = nodeFirst(slideShow),
        lastSlide = nodeLast(slideShow),
        currentSlide = firstSlide,
        swapCounter;

    classAdd(slideShow, 'ss_scripted');
    classAdd(currentSlide, 'ss_show');

    // slideShow functions

    function showCounter() {
        textReplace(slideCounter, 
            Math.floor(swapCounter / 3600) + ':' +
            (Math.floor(swapCounter / 60) % 60) + ':' +
            swapCounter % 60
        );
    }

    function resetCounter() {
        swapCounter = swapTotal;
        showCounter();
    }

    function makeSlide(newSlide) {
        classRemove(currentSlide, 'ss_show');
        currentSlide = newSlide;
        classAdd(currentSlide, 'ss_show');
    }

    function nextSlide() { 
        resetCounter();
        var newSlide = nodeNext(currentSlide);
        if (newSlide) makeSlide(newSlide);
            else if (loopSlideShow) makeSlide(firstSlide);
    }

    function prevSlide() {
        resetCounter();
        var newSlide = nodePrev(currentSlide);
        if (newSlide) makeSlide(newSlide);
            else if (loopSlideShow) makeSlide(lastSlide);
    }

    function slideUpdate() {
        if (swapCounter--) showCounter(); else nextSlide();
    }

    function startSlideShow() {
        resetCounter();
        setInterval(slideUpdate, 1000);
    }

    // wait for onload to actually start the countdown 

    if (window.eventListener) w.addEventListener('load', startSlideShow, false);
        else w.addEventListener('onload', startSlideShow);

})(document);</script>

<style>
    .ss_scripted img { display:none; }
.ss_scripted .ss_show { display:block; }
</style>
</body></html>

我沒有使用NetBeans自行編寫代碼,但僅在將其上傳到根目錄后瀏覽到index1.php時才會發生此錯誤。

您的變量名為$imgPath而不是$imagePath ,因此在此行將其替換:

echo '<img src="', $imageDir, '/', $imagePath, '" alt="slide" />';

您所看到的頁面是Apache在執行請求(例如您的腳本)時出錯時按defaut顯示的頁面。 如您所見,它在開發中並不是很有用,因此您應該嘗試啟用PHP錯誤報告*。

* 如何顯示PHP錯誤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM