Problem on Mysql??
#1

Hello,

I want to return a VARCHAR from the DB which contains "Running like a chicken"

When I have this code:

Код:
public GetBanReason(banid, out[250], type) {
    new query[300];
	if (type == 1) format(query, sizeof(query), "SELECT * FROM PermaBans WHERE BanID = '%i'", banid);
	else format(query, sizeof(query), "SELECT * FROM TempBans WHERE BanID = '%i'", banid);
	mysql_query(mysql, query);
	mysql_store_result();

	if(!mysql_num_rows()) format(out, sizeof(out),"There is no ban information");
 	else {
		new var[250];
 		while (mysql_fetch_row_format("|")) {
	  		mysql_retrieve_row();
			if (type == 1) cache_get_row(0, 4, var);
			else cache_get_row(0, 7, var);
		}
		format(out, sizeof(out),"%s", var);
		format(out, sizeof(out),"%s", var);
		print(out);
 	}
    mysql_free_result();
    
    return 1;
}
the print is:
Running like chicken
LL

Btw I dont know where the LL came from... (is part of the bug..)

Mysql Log: "[18:15:36] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '4', data: "Running like chicken" "

On the other hand if I use this code: (its only one format smaller...)

Код:
public GetBanReason(banid, out[250], type) {
    new query[300];
	if (type == 1) format(query, sizeof(query), "SELECT * FROM PermaBans WHERE BanID = '%i'", banid);
	else format(query, sizeof(query), "SELECT * FROM TempBans WHERE BanID = '%i'", banid);
	mysql_query(mysql, query);
	mysql_store_result();

	if(!mysql_num_rows()) format(out, sizeof(out),"There is no ban information");
 	else {
		new var[250];
 		while (mysql_fetch_row_format("|")) {
	  		mysql_retrieve_row();
			if (type == 1) cache_get_row(0, 4, var);
			else cache_get_row(0, 7, var);
		}
		format(out, sizeof(out),"%s", var);
		print(out);
 	}
    mysql_free_result();
    
    return 1;
}
it prints:
LL
LLULL

And I dont know where it came from...

Mysql Log: " [18:20:37] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '4', data: "Running like chicken" "

Why is it happening? What is happening? how to solve it? is there any better way?

PS: The out variable is empty at the beginning...
Reply
#2

No one?
Reply
#3

You should not ever use fetch_row and retrieve_row at the same time since both functions increase the row pointer. It's probably trying to fetch a second - non-existent - row which returns NULL, breaking the whole thing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)