MySQL Query Result - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL Query Result (
/showthread.php?tid=157952)
MySQL Query Result -
Reynolds - 08.07.2010
How Should I get the MySQL Query's result with G-Stylezz's SQL plugin?
Re: MySQL Query Result -
Niixie - 08.07.2010
Well, what do you need it for.
if you just want to see the result before querying then
1. format
2. print
if you want to see what it is after querying then
1. format
2. query
3. print
if you want to see both then its
1. format
2. print
3. query
4. print
and when i say format its
pawn Код:
format(query, sizeof(query), "SELECT ....
Query is
pawn Код:
mysql_query(query); // Because its the query string
print is
pawn Код:
print(query); // to print what ever is in the query string
Re: MySQL Query Result -
Reynolds - 08.07.2010
No, you misunderstood it. I want to store the RESULT of a MySQL query. I know scripting a lot, but I've never used any MySQL plugins, so that's why I need help.
Re: MySQL Query Result -
Kastranova - 08.07.2010
I'm trying the same, i have this but is still doesn't work.
Код:
new string1[256];
new result1;
format(string1,sizeof(string1),"SELECT `cash` FROM `users` WHERE `username` = '%s' AND `password` = '%s'",playername2, passnow);
result1 = mysql_query(string1);
new stores;
stores = mysql_store_result(result1);
new cash;
new Field[64];
ammount = mysql_fetch_row_format(Field, "|", stores);
cash = mysql_free_result();
format(string, sizeof(string), "Cash Loaded, you have $ %s", cash);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
GivePlayerMoney(playerid,cash);
i want to get the money from the database and use it as player money. but it. in the mysql log it gives the right result but when i want to free that result it prints the query.
Re: MySQL Query Result -
Carlton - 08.07.2010
I have no clue what you're doing in your MySQL query or whatever, I just re-wrote it for you, to save all the trouble. :}
pawn Код:
new
Escape[2][50],
Field[9],
mycash;
mysql_real_escape_strig(playername2, Escape[0]);
mysql_real_escape_strig(passnow, Escape[1]);
format(string1,sizeof(string1),"SELECT * FROM `users` WHERE `username` = '%s' AND `password` = '%s'",Escape[0], Escape[1]);
mysql_query(string1);
mysql_store_result();
if(mysql_retrieve_row()) {
mysql_get_field("cash", Field);
mycash = strval(Field);
}
mysql_free_result();
format(string, sizeof(string), "Cash Loaded, you have $ %s", mycash );
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
GivePlayerMoney(playerid,mycash );
Re: MySQL Query Result -
Kastranova - 08.07.2010
Thanks man, realy needed it
Re: MySQL Query Result -
Niixie - 08.07.2010
pawn Код:
format(query, sizeof(query), "SELECT ...
mysql_query(query);
mysql_store_result();
Now you stored the result? not so hard