Hi all, newbie here but I've got a question and HOPEFULLY someone can assist me here. I'm getting an error that says its on the LAST LINE of my code. Here's the error:

Parse error: syntax error, unexpected ';' in /home/editedreg.php on line 113

Now here's the final lines of the code where this error should be.

$answer = $tSQL->Query("SELECT * FROM `players` WHERE `username` = '" . $username . "' AND `password` = '" . $password . "';");
if (intval($answer[0]) > 0)
{
return true;
}
else
{
return false;
}
$tSQL->Disconnect();
unset($tSQL);
}
                
                if ($qresult) Stop("You successfully got registered");
                else echo Stop("Some mistake with writing to DB");
                [b]([/b]
?>

I put line 113 in bold so you all knew. It's hard to see since the only thing on the line is a "(". Seriously, there is no ";" in the area. What's the deal?

Dani AI

Generated

A few focused checks will find this quickly. PHP often reports a syntax error at the end of the file (or on the last line) when the real problem is an earlier unmatched brace, parenthesis, or stray character. is on point — the fragment shows an extra closing brace — and the lone opening parenthesis on the final line will also trigger parsing failures. Those two things together will explain both the original unexpected ; and the later unexpected $end.

Use the PHP linter and explicit error reporting first:

php -l editedreg.php

and, while debugging, add at the top of the script:

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

If the linter points to a different line than you expect, walk backward from that line looking for an unclosed (, {, or " — the parser often blames the next token or the file end.

Quick manual tricks:

  • Count braces to spot imbalances: grep -o '{' file | wc -l versus grep -o '}' file | wc -l.
  • Use an editor with bracket/paren matching or temporarily comment out large blocks to isolate the broken region.
  • Remove any stray characters at EOF (a single ( or [ will kill parsing).
  • Check for unclosed quotes in strings (e.g., in SQL concatenations).

Final notes: once balanced braces/parentheses and quotes are fixed, the original if ($qresult) echo block suggested by should parse fine. For pure-PHP files, omit the closing ?> to avoid accidental trailing characters.

Recommended Answers

All 3 Replies

change the last lines to this:

if ($qresult)
{
echo "You successfully got registered";
}
else
{
echo "We apologize, there was a mistake with writing the information to the DB";
}

Thank you. However, now I get

Parse error: syntax error, unexpected $end

Missing curly bracket? :P

Looks to me like an extra end brace here, but it is difficult to say since you only posted a fragment of the code

}
$tSQL->Disconnect();
unset($tSQL);
}

Side note: proper indentation of your code blocks would help you spot these things more easily.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.