/addhouse
#1

Hm wassup

pawn Код:
if(strcmp(cmd, "/addhouse", true) == 0)
    {
      tmp = strtok(cmdtext, idx);
      if(!strlen(tmp))
      {
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: Use /addhouse [1-4]");
        return 1;
      }
      if(!IsPlayerAdmin(playerid))
      {
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: Not rcon admin");
            return 1;
      }
      GetPlayerPos(playerid, x, y, z);
      if(strcmp(tmp,"1",true) == 0)
      {
        format(query, 500, "INSERT INTO houses (ex, ey, ez, xx, xy, xz, interior, descr) VALUES (%f,%f,%f,244.5,305.0,999.099975,1,Besit", x, y, z);
        }
        else if(strcmp(tmp,"2",true) == 0)
        {
          format(query, 500, "INSERT INTO houses (ex, ey, ez, xx, xy, xz, interior, descr) VALUES (%f', '%f, '%f','267.100006', '305.0', '999.099975',2,'Besit'", x, y, z);
        }
        else if(strcmp(tmp, "3",true) == 0)
        {
          format(query, 500, "INSERT INTO houses (ex, ey, ez, xx, xy, xz, interior, descr) VALUES (%f, '%f', '%f','301.299987', '306.299987', '1003.5',4,'Besit'", x, y, z);
        }
        else if(strcmp(tmp,"4",true) == 0)
        {
          format(query, 500, "INSERT INTO houses (ex, ey, ez, xx, xy, xz, interior, descr) VALUES (%f, '%f', '%f','344.299987', '305.2', '999.099975',6,'Besit'", x, y, z);
        }
        else
        {
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: Use /addhouse [1-4]");
        return 1;
        }
      samp_mysql_query(query);
      aHouse = CheckRows("houses");
      format(string, sizeof(string), "SERVER: %d houses in the gamemode right now.", aHouse);
      SendClientMessage(playerid, COLOR_WHITE, string);
        return 1;
    }
i get this error:

Код:
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 '' at line 1
can someone help?
Reply
#2

[quote=Pandabeer1337 ]
Hm wassup

pawn Код:
if(strcmp(cmd, "/addhouse", true) == 0)
    {
      tmp = strtok(cmdtext, idx);
      if(!strlen(tmp))
      {
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: Use /addhouse [1-4]");
        return 1;
      }
      if(!IsPlayerAdmin(playerid))
      {
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: Not rcon admin");
            return 1;
      }
      GetPlayerPos(playerid, x, y, z);
      if(strcmp(tmp,"1",true) == 0)
      {
        format(query, 500, "INSERT INTO houses (ex, ey, ez, xx, xy, xz, interior, descr) VALUES (%f,%f,%f,244.5,305.0,999.099975,1,'Besit')", x, y, z);
        }
        else if(strcmp(tmp,"2",true) == 0)
        {
          format(query, 500, "INSERT INTO houses (ex, ey, ez, xx, xy, xz, interior, descr) VALUES (%f, %f, %f,267.100006, 305.0,999.099975,2,'Besit')", x, y, z);
        }
        else if(strcmp(tmp, "3",true) == 0)
        {
          format(query, 500, "INSERT INTO houses (ex, ey, ez, xx, xy, xz, interior, descr) VALUES (%f, %f, %f,301.299987, 306.299987, 1003.5,4,'Besit')", x, y, z);
        }
        else if(strcmp(tmp,"4",true) == 0)
        {
          format(query, 500, "INSERT INTO houses (ex, ey, ez, xx, xy, xz, interior, descr) VALUES (%f, %f, %f,344.299987, 305.2, 999.099975,6,'Besit')", x, y, z);
        }
        else
        {
        SendClientMessage(playerid, COLOR_WHITE, "SERVER: Use /addhouse [1-4]");
        return 1;
        }
      samp_mysql_query(query);
      aHouse = CheckRows("houses");
      format(string, sizeof(string), "SERVER: %d houses in the gamemode right now.", aHouse);
      SendClientMessage(playerid, COLOR_WHITE, string);
        return 1;
    }
Reply
#3

Walrus's solution looks good. If you still have issues try encasing every value in your MYSQL statement with single quotation marks. Also, be careful not to use the single quotation marks within a value that you are sending off to a query, that has messed me up before.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)