有人可以解释为什么我在下面的代码中收到这个错误以及我可以做些什么来修复它,错误指的是:echo "<tr><td>{$r['logID']}</td><td><a href='viewuser.php?u={$r['>{$r['username']}</a> [{$r['userID']}]</td><td>{$r['amount']}</td><td><a href='5050.php?chal={$r['>Challenge</a></td><td>";
在这里把它放到上下文中就是整个片段。
<?php
include "globals.php";
$minbet=1;
$maxg=10;
echo "<big>50 / 50 Crystals Game</big>";
function add_game()
{
global $ir,$t,$userid, $db, $minbet, $maxg;
if(!isset($_POST['amt']))
{
echo "<big>Adding a game</big>
<form action='5050.php?add=1' method='post'>
Amount of crystals:<input type='text' name='amt' size=10 maxlength=10>
<input type='submit' value='Add!'></form>
($maxg games max per user)
<a href='5050.php'>Back</a>";
}
else
{
$_POST['amt'] = abs((int) $_POST['amt']);
if($_POST['amt'] < $minbet)
{
echo "The minimum bet is $minbet
<a href='5050.php?add=1'>Back</a>";exit;
}
$theckcount=$db->query("SELECT logID FROM tchance WHERE userID={$ir['userid']} and active=1");
if($db->num_rows($theckcount) > ($maxg-1))
{
echo "There is a maximum of $maxg games per user.
<a href='5050.php'>Back</a>";exit;
}
if($ir['crystals'] < $_POST['amt'])
{
echo "You cannot afford that amount.
<a href='5050.php'>Back</a>";exit;
}
$db->query("UPDATE users SET crystals = crystals - {$_POST['amt']} WHERE userid = {$ir['userid']}");
$ir['crystals']=$ir['crystals'] - $_POST['amt'];
$db->query("INSERT INTO tchance VALUES ('', {$ir['userid']}, {$_POST['amt']}, 1)");
echo "Your game has been set. Good Luck.
<a href='5050.php'>Back</a>";
}
}
function view_games()
{
global $ir,$t,$userid, $db, $maxg;
$q=$db->query("SELECT t.*, u.username FROM tchance t left join users u on u.userid = t.userID WHERE t.active = 1 ORDER BY t.logID ASC");
echo "<a href='5050.php?add=1'>Add Game</a>
Table of users awaiting a challenge
<table class='table' width=50%><tr><th>Game ID</th><th>User</th><th>Amount</th><th>Challenge</th><th>Cancel</th></tr>";
if($db->num_rows($q) < 1){echo "<tr><td colspan=5>There are currenly no challenges</td></tr>";}
while($r=$db->fetch_row($q))
{
echo "<tr><td>{$r['logID']}</td><td><a href='viewuser.php?u={$r['>{$r['username']}</a> [{$r['userID']}]</td><td>{$r['amount']}</td><td><a href='5050.php?chal={$r['>Challenge</a></td><td>";
if($ir['userid']==$r['userID']){echo "<a href='5050.php?cancel={$r['>Cancel</a>";}
echo "</td></tr>";
}
echo "</table>";
}
function dogame()
{
global $ir,$t,$userid, $db;
$_GET['chal'] = abs((int) $_GET['chal']);
$q=$db->query("SELECT t.*, u.username from tchance t LEFT JOIN users u ON t.userID = u.userid Where t.logID={$_GET['chal']} AND t.active = 1 LIMIT 1");
if($db->num_rows($q) > 0)
{
$r=$db->fetch_row($q);
if($ir['crystals'] < $r['amount'])
{
echo "You cannot afford the challenge amount.
<a href='5050.php'>Back</a>";exit;
}
if($ir['userid'] == $r['userID'])
{
echo "You cannot accept your own challenge.
<a href='5050.php'>Back</a>";exit;
}
if(rand(1,2) == 1)
{
$winner=$r['userID']; $loser=$ir['userid'];
$winnername=$r['username'];
$losername=$ir['username'];
$tstring="Sorry, you Lost. Better luck next time.
<a href='5050.php'>Back</a>";
$db->query("UPDATE users SET crystals = crystals - {$r['amount']} WHERE userid={$ir['userid']}");
$db->query("UPDATE users SET crystals = crystals + ({$r['amount']} * 2) WHERE userid={$r['userID']}");
}
else
{
$winner=$ir['userid']; $loser=$r['userID'];
$winnername=$ir['username'];
$losername=$r['username'];
$tstring="You Won! Congratulations! You Won {$r['amount']} crystals.
<a href='5050.php'>Back</a>";
$db->query("UPDATE users SET crystals = crystals + {$r['amount']} WHERE userid={$ir['userid']}");
}
event_add($winner, "The game of {$r['amount']} crystals challenged by <a href='viewuser.php?u={$r['>{$r['username']}</a> was won by <a href='viewuser.php?u={$winner}'>{$winnername}</a>.", $t);
event_add($loser, "The game of {$r['amount']} crystals challenged by <a href='viewuser.php?u={$r['>{$r['username']}</a> was won by <a href='viewuser.php?u={$winner}'>{$winnername}</a>.", $t);
$db->query("UPDATE tchance SET active = 0 WHERE logID={$_GET['chal']}");
echo $tstring;
}
else
{
echo "This game has either been cancelled or someone played before you got the 5050.
<a href='5050.php'>Back</a>"; exit;
}
}
function cancel()
{
global $ir,$t,$userid, $db;
$_GET['cancel'] = abs((int) $_GET['cancel']);
$q=$db->query("SELECT * from tchance where logID={$_GET['cancel']} AND active = 1");
if($db->num_rows($q) > 0)
{
$r=$db->fetch_row($q);
$db->query("UPDATE users SET crystals = crystals + {$r['amount']} WHERE userid = {$ir['userid']}");
$ir['crystals']=$ir['crystals'] + $r['amount'];
$db->query("UPDATE tchance SET active = -1 WHERE logID = {$_GET['cancel']}");
echo "The game has been cancelled, and your crystals has been returned.
<a href='5050.php'>Back</a>";
}
else
{
echo "This game has already been canceled, does not exist, or someone already played.
<a href='5050.php'>Back</a>";
}
}
if(isset($_GET['cancel'])){cancel();}
elseif(isset($_GET['chal'])){dogame();}
elseif(isset($_GET['add'])){add_game();}
else{view_games();}
?>
感谢您花时间帮助我和教我。