Help (MySQL)
#1

pawn Код:
new CarModelID = GetVehicleModel(GetPlayerVehicleID(t));
    format(query,sizeof(query),"SELECT * FROM `Masinos` WHERE `CarModel` = `%i`", CarModelID);
    samp_mysql_query(query);
    samp_mysql_store_result()
    samp_mysql_fetch_row(line);
           
    new CarNeedStr[128], Float:x,Float:y,Float:z;
    samp_mysql_get_field("CarLevel", str);
    if(pInfo[t][Level] < strval(str)) {
        GetPlayerPos(t,x,y,z);
        format(CarNeedStr,128,"[SERVER]: Siai masinai reikalingas '%i' lygis!",strval(str));
        SendClientMessage(t,lime,CarNeedStr);
        SetPlayerPos(t,x,y,z+5); }
This script starts every 1 second. It checks Car level from table "Masinos" - field "CarLevel". Script gets field "CarLevel" from that column where CarModel = that model id which player car use.
For now i have just 1 column in database, its:
CarName = Landstalker
CarLevel = 10
CarModel = 400

When I enter Landstalker server crashes with these messages:
pawn Код:
[17:14:26] Error in mysql_query: Unknown column '400' in 'where clause'
[17:14:26] Error in mysql_store_result: Unknown column '400' in 'where clause'
Can someone help me ?
Reply
#2

replace, %i with %d and try again
Reply
#3

Quote:
Originally Posted by Pandabeer1337
replace, %i with %d and try again
same problem

can someone else help me ?
Reply
#4

Quote:
Originally Posted by Pandabeer1337
replace, %i with %d and try again
That wouldnt make a difference anyway, i and d are both integers, And replace
pawn Код:
format(query,sizeof(query),"SELECT * FROM `Masinos` WHERE `CarModel` = `%i`", CarModelID);
with
pawn Код:
format(query,sizeof(query),"SELECT * FROM Masinos WHERE CarModel = %i", CarModelID);
Reply
#5

Quote:
Originally Posted by JeNkStAX
Quote:
Originally Posted by Pandabeer1337
replace, %i with %d and try again
That wouldnt make a difference anyway, i and d are both integers, And replace
pawn Код:
format(query,sizeof(query),"SELECT * FROM `Masinos` WHERE `CarModel` = `%i`", CarModelID);
with
pawn Код:
format(query,sizeof(query),"SELECT * FROM Masinos WHERE CarModel = %i", CarModelID);
Thanks a lot! (Virtual handshake)
Reply
#6

EDIT: Solved
Reply
#7

pawn Код:
dcmd_unban(playerid, params[])
{
    if(pInfo[playerid][AdminLvl] > 3 || IsPlayerAdmin(playerid)) {
    new UnBanIp[16], UnBanStr[128];
    if (sscanf(params, "s",UnBanIp)) return SendClientMessage(playerid, red, "[SERVER]: Naudojimas: \"/unban [ip]\"");
    format(query,sizeof(query),"SELECT active FROM Banai WHERE ip = %s",UnBanIp);
    samp_mysql_query(query);
    samp_mysql_store_result()
       
    if(samp_mysql_num_rows() == 0)
    {
        format(UnBanStr,128,"[SERVER]: IP address '%s' doesn't exist in our system",UnBanIp);
        SendClientMessage(playerid,red,UnBanStr);
        return 1;
    }
    else {
   
    format(query,sizeof(query),"SELECT * FROM Banai WHERE ip = %s",UnBanIp);
    samp_mysql_query(query);
    samp_mysql_store_result()
    samp_mysql_fetch_row(line);
   
    samp_mysql_get_field("active", str);
    if(strval(str) == 1) {
    format(query,sizeof(query),"UPDATE Banai SET active = 0 WHERE ip = %s",UnBanIp);
    samp_mysql_query(query);
    format(UnBanStr,128,"[SERVER]: IP address '%s' unbaned!",UnBanIp); }
    else { format(UnBanStr,128,"[SERVER]: IP address '%s' doesn't blocked!",UnBanIp); }
    SendClientMessage(playerid,lime,UnBanStr); }
   
    } else { SendClientMessage(playerid, balta, "SERVER: Unknown command."); }
    return 1;
}
Server crash on /unban [ip] command and i dont know why :/ Can anyone help me ?
Reply
#8

Quote:
Originally Posted by Dreftas
pawn Код:
dcmd_unban(playerid, params[])
{
    if(pInfo[playerid][AdminLvl] > 3 || IsPlayerAdmin(playerid)) {
    new UnBanIp[16], UnBanStr[128];
    if (sscanf(params, "s",UnBanIp)) return SendClientMessage(playerid, red, "[SERVER]: Naudojimas: \"/unban [ip]\"");
    format(query,sizeof(query),"SELECT active FROM Banai WHERE ip = %s",UnBanIp);
    samp_mysql_query(query);
    samp_mysql_store_result()
       
    if(samp_mysql_num_rows() == 0)
    {
        format(UnBanStr,128,"[SERVER]: IP address '%s' doesn't exist in our system",UnBanIp);
        SendClientMessage(playerid,red,UnBanStr);
        return 1;
    }
    else {
   
    format(query,sizeof(query),"SELECT * FROM Banai WHERE ip = %s",UnBanIp);
    samp_mysql_query(query);
    samp_mysql_store_result()
    samp_mysql_fetch_row(line);
   
    samp_mysql_get_field("active", str);
    if(strval(str) == 1) {
    format(query,sizeof(query),"UPDATE Banai SET active = 0 WHERE ip = %s",UnBanIp);
    samp_mysql_query(query);
    format(UnBanStr,128,"[SERVER]: IP address '%s' unbaned!",UnBanIp); }
    else { format(UnBanStr,128,"[SERVER]: IP address '%s' doesn't blocked!",UnBanIp); }
    SendClientMessage(playerid,lime,UnBanStr); }
   
    } else { SendClientMessage(playerid, balta, "SERVER: Unknown command."); }
    return 1;
}
Server crash on /unban [ip] command and i dont know why :/ Can anyone help me ?
Look at JeNkStAX's code and compare.
Reply
#9

Quote:
Originally Posted by Norn
Look at JeNkStAX's code and compare.
He write me that ` doesnt need to be in query, so i dont have them...

Where is the problem?

EDIT: The error is :
pawn Код:
[20:39:37] Error in mysql_query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.255.255' at line 1
[20:39:37] Error in mysql_store_result: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.255.255' at line 1
Here i tried /unban 255.255.255.255
I have to get message that this ip doesnt exist in system, but server just crash..

Help, anyone
Reply
#10

SOLVED
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)