我的一个页面出错

时间:2015-06-05 20:50:59

标签: php html mysql urlencode

我将我的第一个网站上传到互联网。

除了一页之外,在这里和那里进行一些调整后,一切都在工作;在收到错误消息This webpage is not available ERR_TIMED_OUT之前,此页面将永远加载。

当我使用XAMPP在localhost上测试时,我没有遇到此问题。我应该知道有什么共同的原因吗?

可能值得一提的是,这是网站上唯一一个使用urlencode来确定从MySQL显示哪些内容记录的页面。其他页面也使用mysql但没有urlencode。

我会给网站添加一个链接,这样你就可以看到,但是如果它还有问题,我还没准备好让世界看到它。 (我希望你理解

非常感谢任何帮助!

这是该页面的代码

<?php
    session_start();
    $somethingID = $_GET['anIDhere'];

    $username = "x";
    $password = "x";
    $hostname = "x";

    $db_handle = mysql_connect($hostname, $username, $password) or die ("Could not connect to database");
    $selected= mysql_select_db("aDatabaseHere", $db_handle);

    $query = mysql_query("SELECT * FROM something WHERE id ='$somethingID'") or die ("oops");

    //assigns some details about the records found above to some variables
   //
   //
     }                
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><!-- <!doctype html> -->
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
      <title>x</title>
   <link href="../style/style.css" rel="stylesheet" type="text/css"/>
   <link rel="shortcut icon" href="x"/>
   </head>
   <body>
      <div id="header">
         <div id="headerWrap">
            <div id="headerWrapLogo">
               <a href="../index.php"><img id="logo" src="x"/></a>
            </div>
            <div id="headerWrapRest">
              <div id="headerWrapRestTop" >
              </div>
              <div id="headerWrapRestBottom">
                   <div>
                    <a href="somthing">x</a>
                    <a href="somthing">x</a>
                    <a href="somthing">x</a>
                    <a href="somthing">x</a>
                         <div id="searchdiv">
                         <a form which does something and is not the problem>
                    </div>   
                 </div>
              </div>
            </div>
         </div>
      </div>
      <div id="middle">
            <div id="codehere">
               <?php
                  echo $somestuff;
                  echo $otherstuff;
               ?>   
         </div>
         some open source javascript here
   </body>
</html>

我也知道我不应该使用这些msql_方法,我会很快改变这一点,然后才会有人去找我。

2 个答案:

答案 0 :(得分:1)

使用我最后一次观看的Life of Brian电影中的一些引用:

Prophet III: ...through Hebediah, his servants. There shall
in that time be rumours, of things going astray. Ehm...and
there
shall be a great confusion as to where things really are.
And nobody will really know where lieth those little things
wi...with a
sort of rackey work base, that has an attachment. At this
time, a friend shall lose his friend's hammer, and the young
shall not
know where lieth the things possessed by their fathers, that
their fathers put there only just the night before, 'bout
eight
o'clock.

所以使用它,我认为你有一些东西与其他东西有关联,它创造了某些东西误入歧途

答案 1 :(得分:1)

有趣的是Drew Pierce,你需要:

i)检查您的DNS - 是您的网站FTP主机(您放置文件的位置)实际可用于浏览器( http:// )以便在网络上访问?

这可能需要长达24小时。

ii)检查.htaccess文件是否存在任何问题或错误(如果使用),如果有,请将其删除并查看网站是否正确加载。

iii)尝试按CTRL - F5强制从服务器刷新,而不是从任何中间缓存刷新。

<强> 另外

iV)如果您网站上的其他网页有效,那么只需注释掉PHP代码和/或mySQL代码并重新上传,看看网页是否有效。如果是这样,则错误肯定在PHP / MySQL中。

V)使用(v),阅读Stack Overflow并将正确的错误记录插入到您的页面,然后阅读错误日志报告的内容。

vi)强烈建议您不要使用MySQL,而是学习改进的MySQL i ,因为前者已被弃用且不再维护且已满安全漏洞和漏洞。 MySQLi是你应该从这一点开始的方式(也是PDO)。

vii)使用http://redbot.org/之类的网站查看标题信息。查看它是否返回代码200或返回的是什么代码?

viii)为清楚起见 -     $ query = mysql_query(“SELECT * FROM something WHERE id ='$ somethingID'”)或die(“oops”);

应该包含在IF语句中,以便在$somethingID的值为零或非数字时不触发MySQL。 :

if ($somethingID > 0 && is_numeric($somethingId)){ 
    $query = mysql_query("SELECT * FROM something WHERE id ='$somethingID'") or die ("oops");
}

这实际上只是为了整洁,但SQL正在使用可能导致问题的空值进行搜索。