Database not giving right information

Started by Mohamed Boubekri, Mar 23, 2021, 12:20 PM

Previous topic - Next topic

Mohamed Boubekri

Please see the script to understand me :-
function onClientScriptData( player )
{
local int = Stream.ReadInt( ),
string = Stream.ReadString ( );
switch( int.tointeger() )
{
case 74: ////login////

local str2 = Stream.ReadString ( ); ///this password
local q = QuerySQL(Database, "SELECT * FROM Accounts WHERE Username = '"+string+"'"); //i think here is the problem

MessagePlayer("Here what is in data: "+q,player); // the message its appears but what is inserted its appears null
                                             // so when its appears null then can't give right username
// Yep i've check data there is user name with name: MohamedBk
// But when insert my username its show as null
if (!q)
{
if (stats[player.ID].Password == SHA256(str2))
{
MessagePlayer("[#ffff00]Successfully Logged in. Welcome", player);
stats[player.ID].Log = true;
stats[player.ID].UID = player.UID;
stats[player.ID].IP = player.IP;
}
else Stream.StartWrite( ); Stream.WriteInt( 8 ); Stream.SendStream( player );
}
else Stream.StartWrite( ); Stream.WriteInt( 9 ); Stream.SendStream( player );
break;
}
}
We'll, see the image to understand what i meaning:-

And yea, i'm sure 'MohamedBk' is in the data.
In the normal state, MohamedBk need to appears in the message instead null value.
MohamedBk = The name that I registered with, as well as the name in the database (Which should appear in the message)
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

AroliS^

#1
http://wiki.adtec.ovh/wiki/Scripting/Squirrel/Functions/ConnectSQL

You should read the doc of sqlite

local str2 = Stream.ReadString ( ); ///this password
local q = QuerySQL(Database, "SELECT * FROM Accounts WHERE Username = '"+string+"'"); //i think here is the problem

GetSQLColumData is the method to get any colum, at your database. Everything you insert is organized by colums. try counting them and giving the number to this function for getting the information you need.

MessagePlayer("Here what is in data: "+GetSQLColumnData (q, 0),player); // the message its appears but what is inserted its appears null


this shall help you.
Lemme love ya

Mohamed Boubekri

Well, i have select from data player UID.
local str2 = Stream.ReadString ( ); ///this password
local c = QuerySQL(Database, "SELECT * FROM Accounts WHERE UID = '"+player.UID+"'");
local q = GetSQLColumnData(c,1)
MessagePlayer("Here is what inserted: "+q,player); // and yea its appears MohamedBk :)
Thanks for the help, buddy.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].