SA-MP Forums Archive
Little help on sqlite - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Little help on sqlite (/showthread.php?tid=278023)



Little help on sqlite - FireCat - 20.08.2011

Why isn't this writing in the data base?
I know mysql, but i figured out to give a try at sqlite.
It's not writing, why?
pawn Code:
if(dialogid == Registerdialog)
    {
        if(!response) return Kick(playerid);
        new string[200],DBResult:qresult;
        format(string,sizeof(string),""lblue"Welcome "lyellow"%s"lblue"! \n"lwhite"Please enter your "lgreen"password"lwhite" to register your account! \n",GetPName(playerid));
        if(strlen(inputtext) == 0) return ShowPlayerDialog(playerid,Registerdialog,1,""lwhite"Login",string,"Register","Kick");
        format(Query,sizeof(Query),"INSERT INTO `Users` (`Username`, `Password`, `Money`, `Score`, `Kills`, `Deaths`, `Arrests`, `Jailtime`, `Robbed`, `Level`, `RobRank`) VALUES ('%s','%s',0,0,0,0,0,0,0,0,0,0)",GetPName(playerid),inputtext);
        db_free_result(db_query(Users,Query));
        SendClientMessage(playerid,Red,"[REGISTERED] "lgrey"You have been "lblue"registered"lgrey"!");
        qresult = db_query(Users,"SELECT * FROM `Users`");
        SendFMessageToAll(Green,"%s "lblue"has registered. "lyellow"There are now "lwhite"%i "lyellow"registered users in our server.",GetPName(playerid),db_num_rows(qresult));
    }



Re: Little help on sqlite - Lorenc_ - 20.08.2011

Try replace:
pawn Code:
('%s','%s',0,0,0,0,0,0,0,0,0,0)
with

pawn Code:
('%s', '%s', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')
That's how I do it. Works for me.


Re: Little help on sqlite - FireCat - 20.08.2011

Quote:
Originally Posted by Lorenc_
View Post
Try replace:
pawn Code:
('%s','%s',0,0,0,0,0,0,0,0,0,0)
with

pawn Code:
('%s', '%s', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')
That's how I do it. Works for me.
Still doesn't.
How do you create tables?
I used sqlite database browser, but in the first column, i added ID and in ID i added INTEGER PRIMARY KEY for auto increment. Am i doing it wrong?


Re: Little help on sqlite - Lorenc_ - 20.08.2011

pawn Code:
db_free_result(db_query(Database, "CREATE TABLE IF NOT EXISTS `USERS` (`IP`,`NAME`,`ID`)"));
I do it like that, not sure if its "Efficient" but works well


Re: Little help on sqlite - FireCat - 20.08.2011

Quote:
Originally Posted by Lorenc_
View Post
pawn Code:
db_free_result(db_query(Database, "CREATE TABLE IF NOT EXISTS `USERS` (`IP`,`NAME`,`ID`)"));
I do it like that, not sure if its "Efficient" but works well
If i could give you 10000 rep i would give it
THANK YOU!!
Worked perfect