Problem on Mysql?? - 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: Problem on Mysql?? (
/showthread.php?tid=491655)
Problem on Mysql?? -
Joaogl - 31.01.2014
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...
Re: Problem on Mysql?? -
Joaogl - 01.02.2014
No one?
Re: Problem on Mysql?? -
Vince - 01.02.2014
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.