SQL Help
#1

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
Reply
#2

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;
}
Reply
#3

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..).
Reply
#4

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

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.
Reply
#6

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.
Reply
#7

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?
Reply
#8

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.
Reply
#9

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.
Reply
#10

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)