Jump to the post that solved this thread.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 3 Years, 4 Months, 2 Weeks ago [Error Message] 1064 - You have an error in your SQL syntax
#1
Solved: 3 Years, 4 Months, 2 Weeks ago
I'm trying to insert a users hwid under my user table in my database, how ever I get an error thrown in my face when I do so. And the errors says "1064 - You have an error in your SQL syntax" and this is the code I am trying to run in my PHP:
if($user['hwid'] == null){					
	$sql = "UPDATE `db_9b8e03_private`.`users` SET `hwid` = '" + $hwid + "' WHERE `users`.`username` = " + $username;
	$query = $db->query($sql);
	validate_Hwid();
}	

Reply
#2
Solved: 3 Years, 4 Months, 2 Weeks ago
Is db_9b8e03_private your MyBB table?

If it is, you could just use it like this:
if(is_null($user['hwid'])){
	$db->update_query('users', array('hwid' => $hwid), "username='{$username}'");
	validate_Hwid();
}

If not, use it like this:
if(is_null($user['hwid'])){
	$sql = "UPDATE `db_9b8e03_private`.`users` SET `hwid` = '{$hwid}' WHERE `username` = '{$username}'";
	$query = $db->query($sql);
	validate_Hwid();
}
Reply
#3
Solved: 3 Years, 4 Months, 2 Weeks ago
First in the code you are providing you aren't defining $hwid anywhere. Second, you should be running your function that verifies before you update the database so you don't provide the database with invalid data.
Reply
#4
Solved: 3 Years, 4 Months, 2 Weeks ago
(02-29-2016, 08:21 PM)nth Wrote: Is db_9b8e03_private your MyBB table?

If it is, you could just use it like this:
if(is_null($user['hwid'])){
	$db->update_query('users', array('hwid' => $hwid), "username='{$username}'");
	validate_Hwid();
}

If not, use it like this:
if(is_null($user['hwid'])){
	$sql = "UPDATE `db_9b8e03_private`.`users` SET `hwid` = '{$hwid}' WHERE `username` = '{$username}'";
	$query = $db->query($sql);
	validate_Hwid();
}

The first example doe work great as it's the MyBB database, thanks a lot!
Reply
Jump to the post that solved this thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)