MySQL data receiving issue - 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: MySQL data receiving issue (
/showthread.php?tid=394905)
MySQL data receiving issue -
Mmartin - 24.11.2012
Hi. Well simply, I have a very basic script, right.
Код:
link = mysql_connect("localhost","samp","samp","imnotgonnatellyouthis");
if(mysql_ping())
{
printf("MySQL connection is working okay moving on.");
mysql_set_charset("utf8_unicode_ci");
}else{
printf("MYSQL connection is not working. HALT LOL.");
SendRconCommand("stop");
}
Well and then this
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/checksql", cmdtext, true, 10) == 0)
{
new sql[256], str[128], result[256];
mysql_format(link, sql, "SELECT * FROM `%s` WHERE `id` = '%d'", "users", 1);
if(mysql_query("SELECT * FROM users WHERE id=1",-1,-1,link))
{
if(mysql_store_result())
{
if(mysql_fetch_row_format(result))
{
SendClientMessage(playerid,0xffffffff,result);
}
}
}
return 1;
}
return 0;
}
The reason why did I make so many exceptions is that I was testing what can possibly cause the issue. Ignore that.
Well the issue itself is that once I perform the command, I get a value from previous performing. So, let's say that... I perform it first time, it returns an empty string. I do it second time, it returns what it should return the first time. I do it third time, it returns what it should return the second time..
Any ideas?