Lotto mysql "NULL" string ?!
#1

Hello , i'm trying to do the follow system:

- To generate a random number 3 times.
- To check in database 'loterie' if exist a 'bilet' (mean ticket in romanian language) in the database.
- To get the player name from db....
- To check if 'Nume' (player name) is online or offline (i don't know how to check if is online O_O with a string!? )
- To delete everything from db loterie at the final ..
My database :




Errors :
Код:
[20:27:37] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('1')
[20:27:43] [ERROR] CMySQLQuery::Execute - (error #1064) 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 '`Bilet = 262' at line 1
[20:27:43] [WARNING] cache_get_data - no active cache
[20:27:43] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
[20:27:49] [ERROR] CMySQLQuery::Execute - (error #1064) 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 '`Bilet = 365' at line 1
[20:27:49] [WARNING] cache_get_data - no active cache
[20:27:49] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
[20:30:20] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('1')
[20:30:27] [ERROR] CMySQLQuery::Execute - (error #1064) 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 '`Bilet = 325' at line 1
[20:30:27] [WARNING] cache_get_data - no active cache
[20:30:27] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
[20:30:32] [ERROR] CMySQLQuery::Execute - (error #1064) 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 '`Bilet = 270' at line 1
[20:30:32] [WARNING] cache_get_data - no active cache
[20:30:32] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
pawn Код:
Function RezultatLoterie()
{
    lottostate = 1;
    new string[456];
    format(string, sizeof(string), "Se face ~R~prima~W~ extragere..");
    TextDrawSetString(LottoTD1, string);
    for( new playerid = 0; playerid < MAX_PLAYERS; playerid ++ )
    {
        if ( IsPlayerAlreadyLoggedIN[playerid] == 1 )
        {
            TextDrawShowForPlayer(playerid, LottoTD0);
            TextDrawShowForPlayer(playerid, LottoTD1);
        }
    }
    SetTimer( "PrimaExtragere", 4500, 0 );
    return 1;
}
Function PrimaExtragere()
{
    LottoStage = 1;
    new Exist;
    new string[456];
    //new randlotto = 100 + random(300);
    new randlotto = 100; // ---> I want to test if is finding the player
    format( gsString, 256, "SELECT * FROM `loterie` WHERE `Bilet` = '%d'", randlotto);
    new Cache: Result = mysql_query( SQL, gsString ), Get[ 2 ];
    cache_get_data( Get[ 0 ], Get[ 1 ], SQL );
    if( Get[ 0 ] ) Exist = 1; else Exist = 0;
    new numecastigator[50];
    if( Exist == 1 )
    {
        new rand;
        for(new i = 0; i < Get[ 0 ]; i++)
        {
            rand =  cache_get_field_content_int( rand, "ID", SQL );
        }
        new field[129];
        cache_get_field_content( rand, "Nume", field, SQL, sizeof( field ) );
        format( numecastigator, 50, "%s", field );
        format(string, sizeof(string), "Prima extragere - ~R~%s", numecastigator);
        TextDrawSetString(LottoTD2, string);
    }
    if( Exist == 0)
    {
        format(string, sizeof(string), "Prima extragere - ~Y~Nimeni :(", numecastigator);
        TextDrawSetString(LottoTD2, string);
    }
    for( new playerid = 0; playerid < MAX_PLAYERS; playerid ++ )
    {
        if ( IsPlayerAlreadyLoggedIN[playerid] == 1 )
        {
            TextDrawShowForPlayer(playerid, LottoTD2);
        }
    }
    cache_delete( Result );
    format(string, sizeof(string), "Se face ~R~a doua~W~ extragere..");
    TextDrawSetString(LottoTD1, string);
    SetTimer( "ADouaExtragere", 4500, 0 );

}
Function ADouaExtragere()
{
    LottoStage = 2;
    new Exist;
    new string[456];
    new randlotto = 100 + random(300);
    format( gsString, 256, "SELECT * FROM `loterie` WHERE `Bilet = %d", randlotto);
    new Cache: Result = mysql_query( SQL, gsString ), Get[ 2 ];
    cache_get_data( Get[ 0 ], Get[ 1 ], SQL );
    if( Get[ 0 ] ) Exist = 1; else Exist = 0;
    new numecastigator[50];
    if( Exist == 1 )
    {
        new field[129];
        cache_get_field_content( 0, "Nume", field, SQL, sizeof( field ) );
        format( numecastigator, 50, "%s", field );
        format(string, sizeof(string), "A doua extragere - ~R~%s", numecastigator);
        TextDrawSetString(LottoTD3, string);
    }
    else if( Exist == 0)
    {
        format(string, sizeof(string), "A doua extragere - ~Y~Nimeni :(", numecastigator);
        TextDrawSetString(LottoTD3, string);
    }
    for( new playerid = 0; playerid < MAX_PLAYERS; playerid ++ )
    {
        if ( IsPlayerAlreadyLoggedIN[playerid] == 1 )
        {
            TextDrawShowForPlayer(playerid, LottoTD3);
        }
    }
    cache_delete( Result );
    format(string, sizeof(string), "Se face ~R~ultima~W~ extragere..");
    TextDrawSetString(LottoTD1, string);
    SetTimer( "ATreiaExtragere", 4500, 0 );

}
Function ATreiaExtragere()
{
    LottoStage = 3;
    new Exist;
    new string[456];
    new randlotto = 100 + random(300);
    format( gsString, 256, "SELECT * FROM `loterie` WHERE `Bilet = %d", randlotto);
    new Cache: Result = mysql_query( SQL, gsString ), Get[ 2 ];
    cache_get_data( Get[ 0 ], Get[ 1 ], SQL );
    if( Get[ 0 ] ) Exist = 1; else Exist = 0;
    new numecastigator[50];
    if( Exist == 1 )
    {
        new field[129];
        cache_get_field_content( 0, "Nume", field, SQL, sizeof( field ) );
        format( numecastigator, 50, "%s", field );
        format(string, sizeof(string), "A treia extragere - ~R~%s", numecastigator);
        TextDrawSetString(LottoTD4, string);
    }
    else if( Exist == 0)
    {
        format(string, sizeof(string), "A treia extragere - ~Y~Nimeni :(", numecastigator);
        TextDrawSetString(LottoTD4, string);
    }
    for( new playerid = 0; playerid < MAX_PLAYERS; playerid ++ )
    {
        if ( IsPlayerAlreadyLoggedIN[playerid] == 1 )
        {
            TextDrawShowForPlayer(playerid, LottoTD4);
        }
    }
    cache_delete( Result );
    format(string, sizeof(string), "Va uram o seara placuta!");
    TextDrawSetString(LottoTD1, string);
    SetTimer( "StergereaLotto", 4500, 0 );

}
Function StergereaLotto()
{
    LottoStage = 0;
    new Cache: Result = mysql_query( SQL, "SELECT * FROM `loterie`" ), Get[ 2 ];
    cache_get_data( Get[ 0 ], Get[ 1 ], SQL ); // Get[ 0 ] - Rows || Get[ 1 ] - Fields || SQL - connectionHandle
    for(new i = 0; i < LottoID; i++)
    {
        format( gsString, 256, "delete from `loterie` where `ID` = %d", i);
        mysql_tquery( SQL, gsString, "", "" );
    }
    cache_delete( Result );
    lottostate = 0;
    LottoID = 0;
    for( new playerid = 0; playerid < MAX_PLAYERS; playerid ++ )
    {
        if ( IsPlayerAlreadyLoggedIN[playerid] == 1 )
        {
            TextDrawHideForPlayer(playerid, LottoTD0);
            TextDrawHideForPlayer(playerid, LottoTD1);
            TextDrawHideForPlayer(playerid, LottoTD2);
            TextDrawHideForPlayer(playerid, LottoTD3);
            TextDrawHideForPlayer(playerid, LottoTD4);
        }
    }
}
Reply
#2

Quote:

[20:27:43] [ERROR] CMySQLQuery::Execute - (error #1064) 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 '`Bilet = 262' at line 1

Pretty much all you need for debug, just search for
[quote]`Bilet = 262[quote]
You are missing enclosing backtick. So, search for
pawn Код:
format( gsString, 256, "SELECT * FROM `loterie` WHERE `Bilet = %d", randlotto);
//and replace it with
format( gsString, 256, "SELECT * FROM `loterie` WHERE `Bilet` = %d", randlotto);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)