SA-MP Forums Archive
suggestion check - 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: suggestion check (/showthread.php?tid=318966)



suggestion check - Bogdan1992 - 17.02.2012

Hello, well i have a table in database name `suggestion`. Anyway, i wanna check who suggested but anytime when i try the command, it insets me a new row with my name and in suggestion nothing.

PHP код:
CMD:checksuggestion( playerid, params[] )
{
    new 
Query[700], name[24], suggestion[200], string[1000], aux[1000];
    
format(Query, sizeof(Query), "SELECT * FROM `suggestions`");
    
mysql_query(Query);
    
mysql_store_result();
    if(
mysql_num_rows() != 0)
    {
        while(
mysql_fetch_row(Query))
        {
            
mysql_fetch_field_row(name, "user");
            
mysql_fetch_field_row(suggestion, "suggestion");
            
format(aux, sizeof(aux), "{00FF00}User: {FFFFFF}%s\t\t{00FF00}Suggestion: {FFFFFF}%s\n", name, suggestion);
            
strcat(string, aux);
            
ShowPlayerDialog(playerid, 20, DIALOG_STYLE_MSGBOX, "{FFFFFF}Suggestion List", string, "Ok","");
        }
    }
    
mysql_free_result();
    return 
1;
} 



Re: suggestion check - Bogdan1992 - 17.02.2012

bump


Re: suggestion check - dice7 - 17.02.2012

Show the part where you store the suggestions (INSERT INTO ...)


Re: suggestion check - Bogdan1992 - 18.02.2012

PHP код:
    if(dialogid == 20)
    {
        if(
response == 1)
        {
            new 
query[200];
            
GetPlayerName(playerid, pname, sizeof pname);
            
format(query, sizeof(query), "INSERT INTO `suggestions` (`user`, `suggestion`) VALUES ('%s','%s')",pname, inputtext);
            
mysql_query(query);
            
mysql_store_result();
        }
        
mysql_free_result();
    } 



Re: suggestion check - dice7 - 18.02.2012

Print out the inputtext to see if it holds the suggestion. If It's the same as the text you entered in the dialog, then It's a problem with your database


Re: suggestion check - Bogdan1992 - 18.02.2012

well i use almost the same technique on checkban and it works perfect.
Does anyone of you have another solution?


Re: suggestion check - Bogdan1992 - 18.02.2012

I've found the problem, i forgot the check the number of the dialog on checksug, so everytime when i was checking i was added new row with empty name. Anyway thanks.