SQL查询显示2个或更多结果后出现PHP错误

SQL查询显示2个或更多结果后出现PHP错误,php,mysql,Php,Mysql,在我的网站上,我有一个服务器列表(游戏服务器),一旦添加了多个服务器,我就会出现以下错误: Notice: Constant SQ_TIMEOUT already defined in C:\xampp\htdocs\Access\repository\HT2\WH\www.voltzgaming.com\public_html\GlobalBans.php on line 66 Notice: Constant SQ_ENGINE already defined in C:\xampp\ht

在我的网站上,我有一个服务器列表(游戏服务器),一旦添加了多个服务器,我就会出现以下错误:

Notice: Constant SQ_TIMEOUT already defined in C:\xampp\htdocs\Access\repository\HT2\WH\www.voltzgaming.com\public_html\GlobalBans.php on line 66

Notice: Constant SQ_ENGINE already defined in C:\xampp\htdocs\Access\repository\HT2\WH\www.voltzgaming.com\public_html\GlobalBans.php on line 67
下面是GlobalBans.php的完整代码:

<?php require("/Forum/SSI.php"); ?> 
<?php


    require __DIR__ . '/SourceQuery/SourceQuery.class.php';



    $dbhost     = 'localhost';          
    $dbdatabase = 'gbans';          
    $dbuser     = 'root';
    $dbpassword = '';                   
    $webname    = '';
?>
<?php
    $connection = mysql_connect($dbhost,$dbuser,$dbpassword);
    if($connection){mysql_select_db($dbdatabase);}else{die("failed");}
?>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta HTTP-EQUIV="refresh" CONTENT="70" />
        <meta name="keywords" content="ulx, global, ban, banning, bans, gmod, garrys, mod, addon, ulib">
        <title>Global Bans @ Voltz Gaming</title> 
        <link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
        <link rel="stylesheet" href="css/global.css">
        <link href="http://brightboxcdn.com/access/repository/HT1/CDN/www.voltzgaming.com/CSS/Style.css" rel="stylesheet" type="text/css">

    </head>
    <body>
<?php require("/Global/navigation.php"); ?> 

        <div class="BodyTitle">Server List</div>
        <div class="Body">

                <table border="0" class="statuse" width="">
                <tbody>
                    <tr>
                        <td width="28">
                            &nbsp;</td>
                        <td width="182">
                            <strong>IP Address</strong></td>
                        <td width="432">
                            <strong>Server Name</strong></td>
                        <td width="182">
                            <strong>Gamemode</strong></td>
                        <td width="159">
                            <strong>Map</strong></td>
                        <td width="90">
                            <strong>Players</strong></td>
                    </tr>
                </tbody>
            </table>

                </div>
                <?php 
                    $query ="SELECT * FROM servers";
                    $result = mysql_query($query);
                    while($row=mysql_fetch_assoc($result)){     
                ?>
                <?php
                    $ip = $row['IPAddress'];
                    $port = $row['Port'];

                    define( 'SQ_TIMEOUT',     1 );
                    define( 'SQ_ENGINE',      SourceQuery :: SOURCE );

                    $Timer = MicroTime( true );
                    $Query = new SourceQuery( );

                    $Info    = Array( );
                    $Rules   = Array( );
                    $Players = Array( );

                    try
                    {
                        $Query->Connect( $ip, $port, SQ_TIMEOUT, SQ_ENGINE );

                        $Info    = $Query->GetInfo( );
                        $Players = $Query->GetPlayers( );
                    }
                    catch( Exception $e )
                    {
                        $Exception = $e;
                    }

                    $Query->Disconnect( );
                ?> 
                <table width="100%" class="status" border="0">
                    <tr>
                      <td width="30">&nbsp;<img src="css/img/gameicon/gmod.png"/></td>
                      <td width="157"><a href="steam://connect/<?php echo $ip; ?>:<?php echo $port; ?>"><?php echo $ip; ?>:<?php echo $port; ?></a></td>
                        <td width="375"><?php echo $row['HostName']; ?></td>
                        <td width="136"><?php echo htmlspecialchars( $Info[ 'ModDesc' ] ); ?></td>
                        <td width="155"><?php echo htmlspecialchars( $Info[ 'Map' ] ); ?></td>
                        <td width="135"><?php echo htmlspecialchars( $Info[ 'Players' ] ); ?><?php echo '/'; echo htmlspecialchars( $Info[ 'MaxPlayers' ] ); ?></td>
                    </tr>
                </table>
                </div>
                <?php }?>
                <div id="topic-title">
                    <p>&nbsp;</p>

                </div>

        <div class="BodyTitle">Bans - <?php $query ="SELECT COUNT(BanID) FROM bans"; $result = mysql_fetch_array(mysql_query($query)); echo $result[0]; ?> </div><div class="Body">

                <table width="100%" class="statuse" border="0">
                    <tr>
                        <td width="20"></td>
                        <td width="115">
                            <strong>Steam ID</strong>
                        </td>
                        <td width="190">
                            <strong>Stean Username</strong></td>
                        <td width="200">
                            <strong>Reason</strong>
                        </td>
                        <td width="138">
                            <strong>Expires on</strong>
                        </td>
                        <td width="1">
                            <strong>Admin</strong>
                        </td>
                    </tr>
                </table>
                </div>
                </div>
                </div>
                    <?php 
                          $query ="SELECT * FROM servers, bans WHERE servers.ServerID = bans.ServerID ORDER BY BanID DESC";
                                                $result = mysql_query($query);
                                                while($row=mysql_fetch_assoc($result)){  
                    ?>
                <table width="100%" class="status" border="0">
                    <?php
                        $steamid = $row['OSteamID'];                        
                        $steam_id=strtolower($steamid);
                        if (substr($steam_id,0,7)=='steam_0') {
                            $tmp=explode(':',$steam_id);
                        }
                        if ((count($tmp)==3) && is_numeric($tmp[1]) && is_numeric($tmp[2])){
                            $steamidCalc=($tmp[2]*2)+$tmp[1]; 
                            $calckey=1197960265728;
                            $pre=7656;  
                            $steamcid=$steamidCalc+$calckey;
                            $profile="http://steamcommunity.com/profiles/$pre" . number_format($steamcid,0,"","");
                        };
                    ?>
                    <tr>
                        <td width="28">&nbsp;<img src="css/img/gameicon/gmod.png" title="<?php echo $row['HostName']; ?>" width="16" height="16" /></td>
                        <td width="155"><a href="<?php echo $profile; ?>"><?php echo $row['OSteamID']; ?></a></td>
                        <td width="162"><?php echo $row['OName']; ?></td>
                        <td width="323"><?php echo $row['Reason'] ?></td>
                        <td width="185">
                            <?php  if ($row['Length'] == '0')
                                {
                                    echo "<em>Permanent.</em>"; 
                                }
                                elseif($row['Length'] < time())
                                {
                                    echo "Unbanned";    
                                }
                                else
                                {
                                    echo date("g:ia - d M, Y", $row['Length']);
                                }
                            ?>
                        </td>
                        <?php
                            $steamid = $row['ASteamID'];                        
                            $steam_id=strtolower($steamid);
                            if (substr($steam_id,0,7)=='steam_0') {
                                $tmp=explode(':',$steam_id);
                            }
                            if ((count($tmp)==3) && is_numeric($tmp[1]) && is_numeric($tmp[2])){
                                $steamidCalc=($tmp[2]*2)+$tmp[1]; 
                                $calckey=1197960265728;
                                $pre=7656;  
                                $steamcid=$steamidCalc+$calckey;
                                $profile="http://steamcommunity.com/profiles/$pre" . number_format($steamcid,0,"","");
                            };
                        ?>
                        <td width="110"><a href="<?php echo $profile; ?>"><?php echo $row['AName']; ?></a></td>
                    </tr>
                </table>

                <?php }?>
            </div> 
        </div>
        </div>
        <?php echo' <div class="BodySpacer"></div>';     ?>
        <footer>

        </footer>
    </body>
</html>

沃尔茨博彩全球禁令
服务器列表
IP地址
服务器名称
游戏模式
地图
玩家

禁止- 蒸汽ID Stean用户名 原因 于到期 管理 “width=“16”height=“16”/>
您正在while循环中定义这两个常量

    define( 'SQ_TIMEOUT',     1 );
    define( 'SQ_ENGINE',      SourceQuery :: SOURCE );

将它们放在while循环之外。

它可能在循环内吗?请尽可能自己调试,并将导致错误的代码缩减到几行,以便您可以将其发布到此处,而不是链接完整的文件。我不知道,我对这一点不熟悉:(@user3010325然后学习它。每种语言的基础是它的结构/各种类型的变量内容。将它们放在while循环之外。将它们移到这行之前:
while($row=mysql\u fetch\u assoc($result)){
此外:您应该使用更容易区分的变量名,例如:$query与$query-这将在将来的某一天使您或其他人感到困惑