MySQL problem
#1

Ugh, why is this not inserting anything in the mysql?
PHP код:
else if(strcmp(param"create"true) == 0)
    {
        if(
PlayerInfo[playerid][pAdmin] >= 3)
        {
            new 
Float:xFloat:yFloat:zdstring[180], DB_Query[180];
            
GetPlayerPos(playeridxyz);
            if(
ex == (-1) || ey == (-1) || ez == (-1)) return SCM(playeridCOLOR_GREY"/druglab create <ExitXPos>, <ExitYPos>, <ExitZPos>, <Name>");
            
mysql_format(DatabaseDB_Querysizeof(DB_Query), "INSERT INTO `DrugLabs` ( `Name`, `ExitX`, `ExitY`, `ExitZ`, `EntranceX`, `EntranceY`, `EntranceZ`)\
            VALUES ( %s, %f, %f, %f, %f, %f, %f)"
nameexeyezxyz);
             
mysql_tquery(DatabaseDB_Query);
             
format(dstringsizeof(dstring), "Druglab created | Name: %s "name);
             
SCM(playeridCOLOR_YELLOWdstring);
        }
    } 
The command is working because I get the message with the name when I use it but nothing is inserting in the database.
Reply
#2

String values must be enclosed in single quotes. Please always check the error log first.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
String values must be enclosed in single quotes. Please always check the error log first.
There are NO logs...
Reply
#4

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
There are NO logs...
probably because you didn't enable debug. alright so what Vince meant you gotta put string inside two of ' symbols for it work.

so your code gotta be:
Код:
else if(strcmp(param, "create", true) == 0) 
    { 
        if(PlayerInfo[playerid][pAdmin] >= 3) 
        { 
            new Float:x, Float:y, Float:z, dstring[180], DB_Query[180]; 
            GetPlayerPos(playerid, x, y, z); 

            if(ex == (-1) || ey == (-1) || ez == (-1)) return SCM(playerid, COLOR_GREY, "/druglab create <ExitXPos>, <ExitYPos>, <ExitZPos>, <Name>"); 
            mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `DrugLabs` ( `Name`, `ExitX`, `ExitY`, `ExitZ`, `EntranceX`, `EntranceY`, `EntranceZ`)\ 
            VALUES ( '%s', %f, %f, %f, %f, %f, %f)", name, ex, ey, ez, x, y, z); 
             mysql_tquery(Database, DB_Query); 
             format(dstring, sizeof(dstring), "Druglab created | Name: %s ", name); 
             SCM(playerid, COLOR_YELLOW, dstring); 
        } 
    }
Reply
#5

In OnGameModeInit set mysql_log(ALL);
Reply
#6

PHP код:
DB_Query[180
That is usually the monster of your mysql queries because it doesn't query when it does not fit the string value

PHP код:
mysql_format(DatabaseDB_Querysizeof(DB_Query), "INSERT INTO `DrugLabs` ( `Name`, `ExitX`, `ExitY`, `ExitZ`, `EntranceX`, `EntranceY`, `EntranceZ`)\ 
            VALUES ( %s, %f, %f, %f, %f, %f, %f)"
nameexeyezxyz); 
and this kind of query needs a lot of space with the string name, pluz the value of each float, including the query text itself. That db_query string needs to be increased.

but the logs could help you better than what I think.

I'm just saying one possible answer from many possible answers without a log.
Reply
#7

I would also advise you to escape strings, especially when they are player input; the %e specifier does that for you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)