MySQL error.
#1

Hello and thank you for putting some time aside to assist me with my problem.

I'll get right to the point, I was making a register/login system using MySQL, heck, I was not even making a new one, I was using the one I had on one of my old scripts (which worked back then) and I modified it a bit.

Well, basically, what happens is whenever a player registers and I insert all the columns into a table in my database, I receive an error and nothing is changed with the database.

Код:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Password`, `Username`, `AdminLevel`, `Helper`, `Money`, `Level`) VALUES (`%s`, `%s`, '0', '0', '1000', '1')", inputtext, pName[playerid]);
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
Here's the code where I get my error.

Код:
public OnAccountRegister(playerid)
{
    printf("New account registered. ID: %d", pInfo[playerid][ID]);
    pInfo[playerid][ID] = cache_insert_id(mysql);
    return 1;
}
And here's my public, which obviously I forwarded.

Ok, and now to the error, the error I get is

[OnAccountRegister] - (error #1054) Unknown column '456456' in 'field list'

"456456" is the password I input in the register dialog. I tried swapping Username and Password to see what happens and then it says the same just instead of 456456 it says the Username, what am I doing wrong? Is this happening because the code is outdated?
Reply
#2

Try to use "'%s'" instead of "`%s"
Reply
#3

I did that at first, thought to change it to ` ` because it didn't work. Both ways don't work.
Reply
#4

stick with ''s and make sure you have those "`Password`, `Username`, `AdminLevel`, `Helper`, `Money`, `Level`" in "`players`", cause I think that's what this error means.
Reply
#5

You were right, it works. Never happened to me before. But the weird thing is that everything was with ` at first and because it didn't work I switched it to '.

Oh well, thanks.
Reply
#6

Never use user input directly in a query and never store plain text passwords! You have no business with the user's passwords.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)