2014-08-28 69 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