SA-MP Forums Archive
SQL Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SQL Help (/showthread.php?tid=585890)



SQL Help - Luke_James - 17.08.2015

This code...

PHP код:
SQL_SaveLicenses(playerid)
{
    if (!
PlayerData[playerid][pLogged])
        return 
0;
    static
        
query[768];
        
    
format(querysizeof(query), "UPDATE `licenses` SET `licID` = '%d', `ownerID` = '%d', `issuerID` = '%d', `issueDate` = '%s' WHERE `ID` = '%d'",
        
LicenseData[playerid][licID],
        
LicenseData[playerid][ownerID],
        
LicenseData[targetid][issuerID],
        
LicenseData[playerid][issueDate]
    }; 
// this line
    
mysql_function_query(g_iHandlequeryfalse"""");
    return 
1;
// this line 
Gives these errors...

Quote:

error 010: invalid function or declaration
error 010: invalid function or declaration

The lines are highlighted, it's just the brackets


Re: SQL Help - Beckett - 17.08.2015

pawn Код:
SQL_SaveLicenses(playerid)
{
    if (!PlayerData[playerid][pLogged])
        return 0;

    static
        query[768];
         
    format(query, sizeof(query), "UPDATE `licenses` SET `licID` = '%d', `ownerID` = '%d', `issuerID` = '%d', `issueDate` = '%s' WHERE `ID` = '%d'",
        LicenseData[playerid][licID],
        LicenseData[playerid][ownerID],
        LicenseData[targetid][issuerID],
        LicenseData[playerid][issueDate]
    }; // ----> What is this semicolon? Remove it.
    mysql_function_query(g_iHandle, query, false, "", "");
    return 1;
}



Re: SQL Help - arad55 - 17.08.2015

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
pawn Код:
SQL_SaveLicenses(playerid)
{
    if (!PlayerData[playerid][pLogged])
        return 0;

    static
        query[768];
         
    format(query, sizeof(query), "UPDATE `licenses` SET `licID` = '%d', `ownerID` = '%d', `issuerID` = '%d', `issueDate` = '%s' WHERE `ID` = '%d'",
        LicenseData[playerid][licID],
        LicenseData[playerid][ownerID],
        LicenseData[targetid][issuerID],
        LicenseData[playerid][issueDate]
    }; // ----> What is this semicolon? Remove it.
    mysql_function_query(g_iHandle, query, false, "", "");
    return 1;
}
Nope, he should change the curly bracket to a round bracket (because it's meant to close the format function..).


Re: SQL Help - Luke_James - 17.08.2015

Well now I feel a bit stupid, can't believe I didn't see that


Re: SQL Help - Luke_James - 17.08.2015

Perhaps one of you could answer a question though?

PHP код:
    static 
        
query[768]; 
What should that number be? I've just put a random number in so I'm guessing it won't work as intended.


Re: SQL Help - DarkLored - 17.08.2015

pawn Код:
SQL_SaveLicenses(playerid)
{
    if (!PlayerData[playerid][pLogged])
        return 0;

    static
        query[768];
         
    format(query, sizeof(query), "UPDATE `licenses` SET `licID` = '%d', `ownerID` = '%d', `issuerID` = '%d', `issueDate` = '%s' WHERE `ID` = '%d'",
        LicenseData[playerid][licID],
        LicenseData[playerid][ownerID],
        LicenseData[targetid][issuerID],
        LicenseData[playerid][issueDate]
    ); // ----> What is this semicolon? Remove it.
    mysql_function_query(g_iHandle, query, false, "", "");
    return 1;
}
everything seems fine except the bracket that you used with a semi colon, to be honest you don't even need to do it that way and I don't think it works like that in Pawn try using a round bracket instead of a curly one to close formats.

Quote:
Originally Posted by Luke_James
Посмотреть сообщение
Perhaps one of you could answer a question though?

PHP код:
    static 
        
query[768]; 
What should that number be? I've just put a random number in so I'm guessing it won't work as intended.
You count the character count and put how many characters were in the format including spaces.


Re: SQL Help - Luke_James - 17.08.2015

PHP код:
format(querysizeof(query), "UPDATE `licenses` SET `licID` = '%d', `ownerID` = '%d', `issuerID` = '%d', `issueDate` = '%s' WHERE `ID` = '%d'",
        
LicenseData[playerid][licID],
        
LicenseData[playerid][ownerID],
        
LicenseData[targetid][issuerID],
        
LicenseData[playerid][issueDate]
    ); 
All of that?


Re: SQL Help - Beckett - 17.08.2015

Quote:
Originally Posted by arad55
Посмотреть сообщение
Nope, he should change the curly bracket to a round bracket (because it's meant to close the format function..).
I totally didn't see that, I apologize.


Re: SQL Help - arad55 - 17.08.2015

Quote:
Originally Posted by Luke_James
Посмотреть сообщение
PHP код:
format(querysizeof(query), "UPDATE `licenses` SET `licID` = '%d', `ownerID` = '%d', `issuerID` = '%d', `issueDate` = '%s' WHERE `ID` = '%d'",
        
LicenseData[playerid][licID],
        
LicenseData[playerid][ownerID],
        
LicenseData[targetid][issuerID],
        
LicenseData[playerid][issueDate]
    ); 
All of that?
Whatever you format here will be inserted into `query`. If your intended query is longer than 767 characters, it won't send the full query. Though, your array length should be fine for such short query.


Re: SQL Help - Luke_James - 17.08.2015

Quote:
Originally Posted by arad55
Посмотреть сообщение
Whatever you format here will be inserted into `query`. If your intended query is longer than 767 characters, it won't send the full query. Though, your array length should be fine for such short query.
So it just has to be longer than the query itself, not exact?