Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9045667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:24:16+00:00 2026-06-16T11:24:16+00:00

Could someone please explain why I am recieving this error in the below code

  • 0

Could someone please explain why I am recieving this error in the below code and what I can do to fix it, error is referring to : 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>";

To put it into context here is the whole snippet.

<?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();}

?>

Thanks for taking the time to help me and teach me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:24:18+00:00Added an answer on June 16, 2026 at 11:24 am
    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>";
    

    You have “$r[” in the middle of double quotes. Escape it with a slash and you’ll be better off (PHP is trying to evaluate your variable). You probably don’t mean to have $r, but just r

        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>";
    

    I personally think your syntax is confusing, I’d rather use “.” to concatenate the strings and variables:

    echo ' <tr><td>'
             .   $r['logID']
             . '</td><td>'
             .  '<a href="viewuser.php?u=r[' . $r['username'] .']">'.$r['username'].'</a>'
             .  '['.$r['userID'].']</td><td>'
             .  $r['amount'] . '</td><td>'
             . '<a href="5050.php?chal=r">Challenge</a></td><td>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please explain function(tx) in the code snippet below, from this page: http://www.webkit.org/demos/sticky-notes/
Could someone please help explain why I can't get this to work? I properly
Could someone please explain what this code exactly means: for i,j in [(i,j) for
Could someone please explain to me why this simple straight forward code isnt working,
Could someone please explain how to simulate this error? and also what this complains
I don't understand what this code is doing at all, could someone please explain
could someone please explain this java code for me. i find it really hard
Could someone please explain to me whats wrong with this code? #include<stdio.h> struct A{
Could someone please explain this code, this is the same blog app explained on
Could someone please explain what this does and how it is legal C code?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.