Sqlite lil help again :b
#1

Even tho he's registered, when he connects it says to register again.
Why?

pawn Code:
public OnPlayerConnect(playerid)
{
    new DBResult:qresult,string[200];
    format(Query,sizeof(Query),"SELECT * FROM `Users` WHERE `Username` = '%s',",GetPName(playerid));
    qresult = db_query(Users,Query);
    if(db_num_rows(qresult))
    {
        format(string,sizeof(string),""lblue"Welcome back, "lyellow"%s"lblue"! \n"lwhite"Please enter your "lgreen"password"lwhite" to log in your account! \n",GetPName(playerid));
        ShowPlayerDialog(playerid,Logindialog,1,""lwhite"Login",string,"Login","Kick");
    }
    else
    {
        format(string,sizeof(string),""lblue"Welcome "lyellow"%s"lblue"! \n"lwhite"Please enter your "lgreen"password"lwhite" to register your account! \n",GetPName(playerid));
        ShowPlayerDialog(playerid,Registerdialog,1,""lwhite"Register",string,"Register","Kick");
    }
    return 1;
}
Reply
#2

Are the tables made?

pawn Code:
Database = db_open("Conturi.db");
    db_free_result(db_query(Database, "CREATE TABLE IF NOT EXISTS `Users` (`IP`,`Nume`,`Parola`,`Bani`,`Scor`)"));
Example; Stolen off Zh3r0 ( Fastest find, found it in my samp folder. )
Reply
#3

Quote:
Originally Posted by Lorenc_
View Post
Are the tables made?

pawn Code:
Database = db_open("Conturi.db");
    db_free_result(db_query(Database, "CREATE TABLE IF NOT EXISTS `Users` (`IP`,`Nume`,`Parola`,`Bani`,`Scor`)"));
Example; Stolen off Zh3r0 ( Fastest find, found it in my samp folder. )
Yes, it writes in the table.
Reply
#4

Either way that's not the code you should be sharing, but the code where you insert his information (or register) the player into the database. And as Lorenc_ pointed out, make sure you have an active database connection.

EDIT: Did you possibly insert users with the same user name into the database? If that would be true, your code will not work, and you'll need to check if only one result was fetched from the database
pawn Code:
if( db_num_rows( result ) == 1 )
Reply
#5

The codes shown don't seem to be wrong, do you mind showing that part I exampled up?

pawn Code:
new DB: Users; // Common mistake people do.
By the way xD

Ahh

Found the problem. You had a comma at the end.

pawn Code:
format(Query,sizeof(Query),"SELECT * FROM `Users` WHERE `Username` = '%s'",GetPName(playerid));
try this now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)