MySQL code not working.
#1

pawn Код:
format(mysql, sizeof(mysql), "SELECT * FROM `warrants` WHERE `Suspect` = '%s' ORDER BY `ID` DESC", SQL_ReturnEscaped(ReturnName(userid)));
        mysql_function_query(g_iHandle, mysql, true, "", "ds", playerid, ReturnName(userid));
        printf("%s",mysql);
        cache_get_data(rows, fields, g_iHandle);
        string[0] = 0;
        for (new i = 0; i < rows; i ++)
        {
            cache_get_field_content(i, "Description", desc, g_iHandle,128);
            cache_get_field_content(i, "Date", date, g_iHandle,128);
            format(string, sizeof(string), "%s%s (%s)\n", string, desc, date);
        }
        format(desc, sizeof(desc), "Charges: %s", ReturnName(userid));
        Dialog_Show(playerid, ChargeList, DIALOG_STYLE_LIST, desc, string, "Close", "");
Why wouldn't this work? Sorry for asking.
Reply
#2

Excellent question. Why don't my script work either?

Show you mysql log for this question, and provide us some information. Otherwise it'll be impossible for us to help you.
Reply
#3

Okay, the fetching is done correctly, however it's duplicating? I'm not sure why.

Код:
for (new i = 0; i < rows; i ++)
	{
	    cache_get_field_content(i, "Description", desc, g_iHandle,128);
	    cache_get_field_content(i, "Date", date, g_iHandle,128);

	    format(criminal, sizeof(criminal), "%s%s (%s)\n", criminal, desc, date);
	}
Everytime I reopen it, it shows it again, if I open it 3 times, it shows 3 times, ect
Reply
#4

Maybe use

Код:
string[0] = EOS; //EOS = End of string
to empty the string before you format it.
Reply
#5

Edit: I should take a better look on the code before posting next time.
Reply
#6

That's because you're formatting a string and planting the actual string in it.

Look carefully here:

pawn Код:
format(criminal, sizeof(criminal), "%s%s (%s)\n", criminal, desc, date);
If that's not it, I can't tell what because you show us no variables or how you are actually coding that.
Reply
#7

Quote:
Originally Posted by Sinox
Посмотреть сообщение
Maybe use

Код:
string[0] = EOS; //EOS = End of string
to empty the string before you format it.
You're the MPV, good sir.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)