MySQL Query Result
#1

How Should I get the MySQL Query's result with G-Stylezz's SQL plugin?
Reply
#2

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
Reply
#3

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.
Reply
#4

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.
Reply
#5

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 );
Reply
#6

Thanks man, realy needed it
Reply
#7

pawn Код:
format(query, sizeof(query), "SELECT ...
mysql_query(query);
mysql_store_result();
Now you stored the result? not so hard
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)