帮助php空白页?

时间:2009-05-03 05:20:42

标签: php

我经营一个梦幻篮球联赛。我的php网站/ sql数据库旨在让运行团队的人通过网站做所有事情 - 他们可以放弃玩家,玩家自动进入FA池等。

直到大约一周前,一切都运转良好。现在任何时候团队去签署一个玩家,点击“签名”后,他们会得到一个空白的PHP页面。我不知道为什么 - 我没有对任何文件进行调整。它刚刚开始发生。下面是空白PHP页面的代码 - 有人可以帮忙吗?

<?php

$username = "me";
$password = "mypassword";
$database = "mydatabase";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$Team_Offering = $_POST['Team_Name'];
$Fields_Counter = $_POST['counterfields'];
$Roster_Slots = $_POST['rosterslots'];
$Healthy_Roster_Slots = $_POST['healthyrosterslots'];
$Type_Of_Action = $_POST['Action'];

$queryt="SELECT * FROM nuke_ibl_team_info WHERE team_name = '$Team_Offering' ";
$resultt=mysql_query($queryt);

$teamid=mysql_result($resultt,0,"teamid");

$Timestamp = intval(time());


// ADD TEAM TOTAL SALARY FOR THIS YEAR

$querysalary="SELECT * FROM nuke_iblplyr WHERE teamname = '$Team_Offering' AND retired = 0 ";
$results=mysql_query($querysalary);
$num=mysql_numrows($results);
$z=0;

while($z < $num)
    {
        $cy=mysql_result($results,$z,"cy");
        $cyy = "cy$cy";
        $cy2=mysql_result($results,$z,"$cyy");
        $TotalSalary = $TotalSalary + $cy2;
        $z++;
    }

//ENT TEAM TOTAL SALARY FOR THIS YEAR

$k=0;
$Salary=0;

while ($k < $Fields_Counter)
{
$Type=$_POST['type'.$k];
$Salary=$_POST['cy'.$k];
$Index=$_POST['index'.$k];
$Check=$_POST['check'.$k];
$queryn="SELECT * FROM nuke_iblplyr WHERE pid = '$Index' ";
$resultn=mysql_query($queryn);
$playername=mysql_result($resultn,0,"name");
$players_team=mysql_result($resultn,0,"tid");

if ($Check == "on")
  {
  if ($Type_Of_Action == "drop")
    {
      if ($Roster_Slots < 4 and $TotalSalary > 7000)
        {

          echo "You have 12 players and are over $70 mill hard cap.  Therefore you can't drop a player! <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment.  If you are not redirected, click the link.";

        }else{

          $queryi = "UPDATE nuke_iblplyr SET `ordinal` = '1000', `droptime` = '$Timestamp' WHERE `pid` = '$Index' LIMIT 1;";
          $resulti=mysql_query($queryi);

          $topicid=32;
          $storytitle=$Team_Offering." make waiver cuts";
          $hometext="The ".$Team_Offering." cut ".$playername." to waivers.";

          // ==== PUT ANNOUNCEMENT INTO DATABASE ON NEWS PAGE 
          $timestamp=date('Y-m-d H:i:s',time());

          $querycat="SELECT * FROM nuke_stories_cat WHERE title = 'Waiver Pool Moves'";
          $resultcat=mysql_query($querycat);
          $WPMoves=mysql_result($resultcat,0,"counter");
          $catid=mysql_result($resultcat,0,"catid");

          $WPMoves=$WPMoves+1;

          $querycat2="UPDATE nuke_stories_cat SET counter = $WPMoves WHERE title = 'Waiver Pool Moves'";
          $resultcat2=mysql_query($querycat2);

          $querystor="INSERT INTO nuke_stories (catid,aid,title,time,hometext,topic,informant,counter,alanguage) VALUES ('$catid','Associated Press','$storytitle','$timestamp','$hometext','$topicid','Associated Press','0','english')";
          $resultstor=mysql_query($querystor); 
          echo "<html><head><title>Waiver Processing</title>
            </head>
            <body>
            Your waiver moves should now be processed.  <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment.  If you are not redirected, click the link.
            </body></html>";
        }

    } else {
      if ($players_team == $teamid)
        {
          $queryi = "UPDATE nuke_iblplyr SET `ordinal` = '800', `teamname` = '$Team_Offering', `tid` = '$teamid' WHERE `pid` = '$Index' LIMIT 1;";
          $resulti=mysql_query($queryi);
          $Roster_Slots++;

          $topicid=33;
          $storytitle=$Team_Offering." make waiver additions";
          $hometext="The ".$Team_Offering." sign ".$playername." from waivers.";

          // ==== PUT ANNOUNCEMENT INTO DATABASE ON NEWS PAGE 

          $timestamp=date('Y-m-d H:i:s',time());

          $querycat="SELECT * FROM nuke_stories_cat WHERE title = 'Waiver Pool Moves'";
          $resultcat=mysql_query($querycat);
          $WPMoves=mysql_result($resultcat,0,"counter");
          $catid=mysql_result($resultcat,0,"catid");

          $WPMoves=$WPMoves+1;

          $querycat2="UPDATE nuke_stories_cat SET counter = $WPMoves WHERE title = 'Waiver Pool Moves'";
          $resultcat2=mysql_query($querycat2);

          $querystor="INSERT INTO nuke_stories (catid,aid,title,time,hometext,topic,informant,counter,alanguage) VALUES ('$catid','Associated Press','$storytitle','$timestamp','$hometext','$topicid','Associated Press','0','english')";
          $resultstor=mysql_query($querystor); 
          echo "<html><head><title>Waiver Processing</title>
            </head>
            <body>
            Your waiver moves should now be processed.  <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment.  If you are not redirected, click the link.
            </body></html>";

        } else {

          if ($Healthy_Roster_Slots < 4 and $TotalSalary + $Salary > 7000)
          {

              echo "You have 12 or more healthy players and this signing will put you over $70.  Therefore you can not make this signing. <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment.  If you are not redirected, click the link.";

          } elseif ($Healthy_Roster_Slots > 3 and $TotalSalary + $Salary > 7000 and $Salary > 103) {

              echo "You are over the hard cap and therefore can only sign players who are making veteran minimum contract! <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment.  If you are not redirected, click the link.";

          } elseif ($Healthy_Roster_Slots < 1) {
              echo "You have full roster of 15 players.  You can't sign another player at this time! <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment.  If you are not redirected, click the link.";

          } else {

              $queryi = "UPDATE nuke_iblplyr SET `ordinal` = '800', `bird` = '0', `cy` = '1', `cy1` = '$Salary', `teamname` = '$Team_Offering', `tid` = '$teamid' WHERE `pid` = '$Index' LIMIT 1;";
              $resulti=mysql_query($queryi);
              $Roster_Slots++;

              $topicid=33;
              $storytitle=$Team_Offering." make waiver additions";
              $hometext="The ".$Team_Offering." sign ".$playername." from waivers.";

              // ==== PUT ANNOUNCEMENT INTO DATABASE ON NEWS PAGE 

              $timestamp=date('Y-m-d H:i:s',time());

              $querycat="SELECT * FROM nuke_stories_cat WHERE title = 'Waiver Pool Moves'";
              $resultcat=mysql_query($querycat);
              $WPMoves=mysql_result($resultcat,0,"counter");
              $catid=mysql_result($resultcat,0,"catid");

              $WPMoves=$WPMoves+1;

              $querycat2="UPDATE nuke_stories_cat SET counter = $WPMoves WHERE title = 'Waiver Pool Moves'";
              $resultcat2=mysql_query($querycat2);

              $querystor="INSERT INTO nuke_stories (catid,aid,title,time,hometext,topic,informant,counter,alanguage) VALUES ('$catid','Associated Press','$storytitle','$timestamp','$hometext','$topicid','Associated Press','0','english')";
              $resultstor=mysql_query($querystor); 
              echo "<html><head><title>Waiver Processing</title>
                </head>
                <body>
                Your waiver moves should now be processed.  <br>You will be automatically redirected to <a href=\"http://www.chibul.com/iblv2\">the main IBL page</a> in a moment.  If you are not redirected, click the link.
                </body></html>";

            }
        }
    }
  }
$k++;
}

?>

10 个答案:

答案 0 :(得分:11)

在打开的PHP标记后面加上以下内容:

error_reporting(E_ALL);
ini_set('display_errors', 'On');

如果这不起作用,可能存在解析错误,那么您需要检查错误日志。

您还需要转义您在查询中添加的值。这可能导致MySQL查询失败。如果有人在$ _POST ['Team_Name']中放入",您的第一个查询可能会失败。

另一个最终可能的问题:你确定它仍然可以连接到MySQL吗?

找到问题的一个选项是注释掉大部分代码,然后逐段取消注释。

修改:首先问题是mysql_connect行。需要更改为,请注意引号:mysql_connect('localhost',$username,$password);此外,变量$result$queryt在此行拼写错误并用于正确的拼写:$resultt=mysql_query($queryt);我没有检查其余的,但可能会有其他错误导致您的脚本中断。一些错误列表很重要,但不会破坏您的脚本。

转义:查看以下页面:http://php.net/manual/en/function.mysql-escape-string.php这基本上可以防止人们删除整个数据库。

检查this page上的示例代码,了解如何连接到MySQL并检查您是否已连接。

另一个建议:您确定没有任何查询失败吗?您可能希望在继续之前检查查询结果是否为false,例如:

if ($resultcat2 === false) {
    trigger_error('query failed ' . $sql, E_USER_ERROR);
    echo 'Sorry, there was a problem processing your request. Please try again later.';
    exit;
}

答案 1 :(得分:2)

在php.ini文件中打开PHP的错误报告,看看是否报告了任何错误或警告。还可以尝试删除文件末尾之前的尾随空格吗?&gt;,这在过去给我带来了问题。

答案 2 :(得分:2)

为上述部分回复添加了评论。请尽量为我愚蠢 - 我对此非常陌生。但是,当我对代码没有任何改变时,我无法弄清楚为什么它会突然停止工作。

答案 3 :(得分:2)

如果您没有对任何文件进行任何更改而且它只是“破坏”那么这表明您的webhost通过配置更改,您的数据库以某种方式被清除,或者其他人可能已经更改了某些内容。

在每一个

之后帮助发现罪魁祸首
if{
else{
while{

或/和每个语句之后(语句以分号结尾;)将其添加到下一行

print "<br> made it to this label: some_unique_label_name_here";

每次都应该替换标签,以帮助您跟踪代码。 这将是您调试脚本的第一步,以确定代码执行的范围。

答案 4 :(得分:0)

如果没有详细介绍您的代码,我建议您查找可能会循环很长时间的任何部分,而不返回

答案 5 :(得分:0)

启用错误报告后,请确保放入与所有if语句对应的else语句,以便确定是否触发了这些语句。抛出一些回声。

答案 6 :(得分:0)

此外,澄清一下 - 我在网站上可能有三十几个PHP文件 - 这是唯一一个停止工作的文件。

答案 7 :(得分:0)

这就是我得到的地方......如果我把打印线放在它下面,打印线下面的所有东西都不会出现。

$k=0;
$Salary=0;

print "<br> made it to this label: some_unique_label_name_here";

while ($k < $Fields_Counter)

{

$Type=$_POST['type'.$k];

$Salary=$_POST['cy'.$k];

$Index=$_POST['index'.$k];

$Check=$_POST['check'.$k];


$queryn="SELECT * FROM nuke_iblplyr WHERE pid = '$Index' ";
$resultn=mysql_query($queryn);

$playername=mysql_result($resultn,0,"name");

$players_team=mysql_result($resultn,0,"tid");

答案 8 :(得分:0)

另外,您应该更改get或post中的每个变量,例如:

$Team_Offering = $_POST['Team_Name'];

$Team_Offering = mysql_real_escape_string($_POST['Team_Name']);

在mysql查询中使用它之前,否则你可能会受到SQL注入攻击。

答案 9 :(得分:0)

所以更新......没有。洛尔

如果您查看此代码:

$k=0;

$工资= 0;

print“
使它成为这个标签:some_unique_label_name_here”;

while($ k&lt; $ Fields_Counter)

{

$类型= $ _ POST [ '类型' $ķ。];

$工资= $ _ POST [ 'CY' $ķ。];

$指数= $ _ POST [ '索引' $ķ。];

$检查= $ _ POST [ '检查' $ķ。];

$ queryn =“SELECT * FROM nuke_iblplyr WHERE pid ='$ Index'”; $ resultn =的mysql_query($ queryn);

$ playername = mysql_result($ resultn,0, “名称”);

$ players_team = mysql_result($ resultn,0, “TID”);

如果我将下面的打印声明放在下面,则页面会变为空白并且不会显示。如果print语句在while之前,则语句会显示,但页面上没有任何操作。最终结果是,在运行此页面时,应从自由代理中删除在上一页上选择的播放器,添加到用户的团队,并在首页上发布一个故事,宣布它。显然这些都不会发生在这里。