sqlite read issue
#1

Hello,

I am trying to read from my database here. As you can see i tried many things XD (if you look at the // )


pawn Код:
ReadVehicle(playerid);
public ReadVehicle(playerid)
{
    new query[256],string[128];
    new DBResult:qresult;
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
//SELECT vehicleinfo FROM vehicleinfo WHERE username = '%s' AND slotid = %d", pname, slotid);
    //format(string,sizeof(string),"SELECT Level FROM `users` WHERE Username = '%s'", PlayerName[playerid]);
    //format(query,sizeof(query),"SELECT stat FROM `Users` WHERE `Name`= '%s'",pName);
    //format(query,sizeof(query),"SELECT Name FROM `Users` WHERE `Name`= '%s'",pName);
   
    //format(query, sizeof(query), "SELECT Users FROM Users WHERE name = '%s'",pName);
    format(query, sizeof(query), "SELECT Users FROM `Users` WHERE name = '%s'",pName);
    qresult = db_query(testdb,string);
   
    //if(db_num_rows(qresult) == 1)
   // {
        db_get_field_assoc(qresult,"name",string,6);
        format(string,sizeof(string),"%s",strval(string));
        SendClientMessage(playerid,0xAFAFAFAA,string);
    //}
    db_free_result(qresult);
}
I'm very confused now and i need help, i just want it to read the name out of the database and sends a clientmessage to confirm that it did. All it does now is sending an empty string

Thanks in advance
Reply
#2

Try this:

pawn Код:
ReadVehicle(playerid);
public ReadVehicle(playerid)
{
    new query[256],string[128];
    new DBResult:qresult;
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
//SELECT vehicleinfo FROM vehicleinfo WHERE username = '%s' AND slotid = %d", pname, slotid);
    //format(string,sizeof(string),"SELECT Level FROM `users` WHERE Username = '%s'", PlayerName[playerid]);
    //format(query,sizeof(query),"SELECT stat FROM `Users` WHERE `Name`= '%s'",pName);
    //format(query,sizeof(query),"SELECT Name FROM `Users` WHERE `Name`= '%s'",pName);
   
    //format(query, sizeof(query), "SELECT Users FROM Users WHERE name = '%s'",pName);
    format(query, sizeof(query), "SELECT Users FROM `Users` WHERE name = '%s'",pName);
    qresult = db_query(testdb,query);
   
    //if(db_num_rows(qresult) == 1)
   // {
        db_get_field_assoc(qresult,"name",string,6);
        format(string,sizeof(string),"%s",strval(string));
        SendClientMessage(playerid,0xAFAFAFAA,string);
    //}
    db_free_result(qresult);
}
Reply
#3

Same result, ingame i see an empty message maybe its just something wrong with the string but i just dont see it.

Edit: its not the string thats wrong it just doesnt do anything between this;

pawn Код:
if(db_num_rows(qresult) == 1)   //
{
db_get_field_assoc(qresult,"name",string,6);
format(string,sizeof(string),"%s",strval(string));
SendClientMessage(playerid,0xAFAFAFAA,string);
}
So my guess is i mixed up something else with the database part select from where :S
Reply
#4

Still cant make it read the database any help please ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)