0

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 '('RealName') VALUES ('Louise T') WHERE SteamID='7656119801402xxxx'' at line 1

$mysql_hostname = "localhost";
$mysql_user = "xxxx";
$mysql_password = "xxxx";
$mysql_database = "xxxx";
$prefix = "";
$conn = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
$connect = mysql_select_db($mysql_database, $conn);


$realname = 'Louise T';
$steamid = '7656119801402xxxx';

$sql="UPDATE users SET ('RealName') VALUES ('". mysql_real_escape_string($realname)  ."') WHERE SteamID='$steamid'";
if (!mysql_query($sql))
{
    die('Error: ' . mysql_error());
} else {
    header("Location: index.php");
    exit();
}

I don't know what this is caused by? I have been checking every single word for if it were interfering with some of the MySQL commands and still seem to get this error..

This is some rules I found online:

  1. You have omitted, or included an unnecessary symbol: !@#$%^&*()-_=+[]{}|;:'",<>/?
  2. A misplaced, missing or unnecessary keyword: select, into, or countless others.
  3. You have unicode characters that look like ascii characters in your query but are not recognized.
  4. Misplaced, missing or unnecessary whitespace or newlines between keywords.
  5. Unmatched single quotes, double quotes, parenthesis or braces.

But I really don't think there is anything like it?

Dharman
  • 30,962
  • 25
  • 85
  • 135
bilbodog
  • 231
  • 1
  • 5
  • 15
  • Does this answer your question? [When to use single quotes, double quotes, and backticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql) – Dharman Sep 20 '20 at 20:38

1 Answers1

3

Your update query is invalid because SET ('RealName') VALUES not a valid Syntax more details

use update like that :-

UPDATE users SET RealName='$realname' WHERE SteamID='$steamid'

For insert :-

Insert into users (RealName) values ('$steamid')
Abhishek Sharma
  • 6,689
  • 1
  • 14
  • 20