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?

1

1 Answer 1

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')
Sign up to request clarification or add additional context in comments.

2 Comments

thanks... for your support to improving my answer :) - @Drew
Thanks a lot. I get it is just me, there is a little (much) rusty. Long time since I had with SQL to do. Waow. That is embarrassing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.