2014-08-28 45 views
0

所以我有一個MySQL數據庫,我已經把它連接到一些PHP和HTML文件。我的php文件位於localhost文件夾中。當我運行我的測試html文件,這也是我的localhost文件夾,它沒有問題找到該文件,但是當我有一個名爲「SriMeru」我的localhost文件夾中的子文件夾,其中我有我的實際html文件格式和其他東西與最終的PHP文件,該HTML文件無法找到該PHP文件。下面是在HTML文件中的一些代碼:本地主機上的奇怪的404錯誤

<div id="mmargin" style="background-color:#F1ECDF;height:810px;width:600px;float:left;"> 
     <p id = "myDiv">no</p> 
    <script> 
     function loadPHPDoc(str){ 
     var xmlhttp; 
     if (window.XMLHttpRequest) 
     {// code for IE7+, Firefox, Chrome, Opera, Safari 
     xmlhttp=new XMLHttpRequest(); 
     } 
     else 
     {// code for IE6, IE5 
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
     } 
     xmlhttp.onreadystatechange=function() 
     { 
     if (xmlhttp.readyState==4 && xmlhttp.status==200) 
      { 
      document.getElementById("myDiv").innerHTML=xmlhttp.responseText; 
      } 
     else{ 
      document.getElementById("myDiv").innerHTML="failure"; 
     } 
     } 
     xmlhttp.open("POST","srimeru/forumSubmit.php",true); 
     xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); 
     var sender = "q=" + str; 
     xmlhttp.send(sender); 
     } 

    </script> 

     <p> 
    Message <input type= "text" id="messbox"> 
    <button type= "button" onclick="loadPHPDoc(document.getElementById('messbox').value)">input</button> 
     </p> 
</div> 

,這裏是我的PHP文件中的代碼:

<?php 

    $q = $_POST["q"]; 

    $messData = mysqli_connect("localhost", "root", "chendu", "SriMeru"); 
    if (mysqli_connect_errno()){ 
     echo "Failed to connect to Server"; 
    } 
    $sql = "INSERT INTO messages VALUES ('".$q."')"; 
    mysqli_query($messData, $sql); 
    echo "<p>success</p>"; 

    mysqli_close($messData); 
?> 

在HTML文件中的其它地方,我有涉及帳篷和定時器一些奇怪的格式,我知道,如果不這可能會搞砸了。

+3

SriMeru = srimeru – 2014-08-28 00:55:26

+0

邊注:一般認爲使用'marquee'任何人都不應取出回射。 – 2014-08-28 00:58:11

+0

我明白了,謝謝。打擾大門,這是我第一次製作網站。 – 2014-08-28 01:15:22

回答

2

「但是當我我叫本地主機文件夾中有一個子文件夾‘SriMeru’在那裏我有我的實際的HTML文件」

你說你的文件夾名爲SriMeru

在很多系統上(包括UNIX/LINUX),SriMerusrimeru不是同一回事;它們區分大小寫。

因此,無論是重命名文件夾是所有小寫字母,或更改srimeru/forumSubmit.phpSriMeru/forumSubmit.php

+0

這不是它,但謝謝,我想通了 – 2014-08-28 18:42:39

+0

@ChristianColomb不客氣基督徒。我很想知道它是什麼。 – 2014-08-28 19:04:27

+0

我需要說/SriMeru/forumSubmit.php – 2014-08-31 04:24:15