SA-MP Forums Archive
[HELP] MySQL INSERT INTO query. - 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: [HELP] MySQL INSERT INTO query. (/showthread.php?tid=602147)



[HELP] MySQL INSERT INTO query. - BornHuman - 03.03.2016

So, I have this query to insert some information into table 'mdc', the sole purpose for adding offline crimes.

pawn Код:
forward OnCrimeAddOffline(iPlayerID, szAddCrime[], szPName[], iExtra);
public OnCrimeAddOffline(iPlayerID, szAddCrime[], szPName[], iExtra)
{

    new
        iRows,
        iTempID;

    iRows = cache_get_row_count(MainPipeline);

    switch(iExtra) {
        case 0: {
           
            if(!iRows) return SendClientMessageEx(iPlayerID, 0xFFFFFF, "That player was not found!");


            iTempID = cache_get_field_content_int(iRows, "id", MainPipeline);

            format(szMiscArray, sizeof(szMiscArray), "INSERT INTO `mdc` (`id` ,`time` ,`issuer` ,`crime`, `origin`) VALUES ('%d',NOW(),'%s','%s','%d')", iTempID, GetPlayerNameEx(iPlayerID), szAddCrime, arrGroupData[PlayerInfo[iPlayerID][pMember]][g_iAllegiance]);
            mysql_function_query(MainPipeline, szMiscArray, true, "OnCrimeAddOffline", "dssd", iPlayerID, szAddCrime, szPName, 1);

            DeletePVar(iPlayerID, "OfflineSU");
        }

        case 1: {
           
            if(!cache_affected_rows(MainPipeline)) return SendClientMessageEx(iPlayerID, 0xFFFFFF, "There was an issue appending that crime!");

            format(szMiscArray, sizeof(szMiscArray), "Crime Added: %s - %s", szPName, szAddCrime);
            SendClientMessage(iPlayerID, 0xFFFFFF, szMiscArray);
        }
    }


    return 1;
}
It does return saying "Crime added, blah blah". However, the crimes are not showing up in the table. It's as if it's not inserting anything (because it's not)

Any suggestions?


Re: [HELP] MySQL INSERT INTO query. - itsCody - 03.03.2016

Check server logs for the error, if none are present, add this somewhere inside of your gamemode, re run the command and review the errors.

PHP код:
public OnQueryError(erroriderror[], callback[], query[], connectionHandle)
{
    new 
string[100];
    
printf("Error ID: %i"errorid);
    
printf("Error: %s"error);
    
printf("Callback: %s"callback);
    
printf("Query: %s"query);
    return 
1;




Re: [HELP] MySQL INSERT INTO query. - BornHuman - 03.03.2016

Quote:
Originally Posted by itsCody
Посмотреть сообщение
Check server logs for the error, if none are present, add this somewhere inside of your gamemode, re run the command and review the errors.

PHP код:
public OnQueryError(erroriderror[], callback[], query[], connectionHandle)
{
    new 
string[100];
    
printf("Error ID: %i"errorid);
    
printf("Error: %s"error);
    
printf("Callback: %s"callback);
    
printf("Query: %s"query);
    return 
1;

Already have that defined. No errors are showing up in the console unfortunately.