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

  • SEARCH
  • Home
  • 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 7712537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:39:26+00:00 2026-06-01T01:39:26+00:00

I’m attempting to connect to an api and get a user from a donation

  • 0

I’m attempting to connect to an api and get a user from a donation system and then open a socket to a game to automatically give a user the amount they donated for. I need to get rid of this error:
“You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘$r’ at line 1”

I can’t seem to see what the problem is? Here’s the script:

<?php
$tablename="CENSORED";
$DBUSER="CENSORED";
$DBPASSWORD="CENSORED";
$DBHOST="CENSORED";
?>
<?php

$urlMask = 'CENSORED';    

$getUser = function($id) use ($urlMask) {
    list($user) = json_decode(file_get_contents(sprintf($urlMask, $id)));
    return (object) $user;
};

$user = $getUser(4087396);

$Username = $user->user->username;
$Rank = $user->item_name;
$IGN = $user->custom_field;
echo '<center> Your username is '.$IGN.' correct? </center> ';
?>

<?php
if(isset($_POST['Clickbutton'])){

    $con = mysql_connect($DBHOST,$DBUSER,$DBPASSWORD);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());

  }
mysql_select_db($tablename, $con);
$sql="SELECT IGN FROM fisktable WHERE IGN='$IGN' and Rank='$Rank'" ;
$r = mysql_query($sql);
if(!$r) {
   $err=mysql_error();
   print $err;
}

    $result = mysql_query('$r') or die(mysql_error());
    if(mysql_num_rows($result) == 1) {
echo 'That username has already been given their rank!';
    } else {
         $HOST = "77.45----"; //the ip of the bukkit server
         $password = "chdfxfdxh";
        //Can't touch this:
        $sock = socket_create(AF_INET, SOCK_STREAM, 0)
        or die("error: could not create socket\n");
        $succ = socket_connect($sock, $HOST, 4445) 
        or die("error: could not connect to host\n");
        //Authentification
        socket_write($sock, $command = md5($password)."<Password>", strlen($command) + 1)
        or die("error: failed to write to socket\n");
        //Begin custom code here.
        socket_write($sock, $command = "/Command/ExecuteConsoleCommand:pex user ($IGN) group set ($Rank);", strlen($command) + 1) //Writing text/command we want to send to the server
        or die("error: failed to write to socket\n");
        socket_write($sock, $command = "Thanks, ($IGN) for donating to the ($Rank) rank! ;", strlen($command) + 1)
        or die("error: failed to write to socket\n");
    mysql_select_db($tablename, $con);
$sql="INSERT INTO $tablename(IGN,Rank) VALUES ('$IGN','$Rank')" ;
        exit();
}}
?>
<center>
<form method="POST">
<input name="Clickbutton" type="submit" value="Yes! I would like to receive my rank!"/> 
</form>
</center>

I’m trying to check if the user has been already given their rank and items by adding them to a database when their given their items. And then if they try to do it twice they will get an error saying that they have already been given their rank!

If you see any other problems or potental problems feel free to point them out.
Thanks!

  • 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-01T01:39:28+00:00Added an answer on June 1, 2026 at 1:39 am

    Basic PHP syntax error:

    $result = mysql_query('$r') or die(mysql_error());
                          ^--^--- remove the quotes
    

    single quoted strings do not interpolate values. You’re passing a literal $ and r to mysql as a query.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.