Posts: 177
Threads: 28
Joined: Mar 2011
Reputation:
0
Right, i would like to grab the following:
'ip' from 'users'.
So it would be
SELECT 'ip' FROM 'users' WHERE 'username' = %s. Yep? Got that.
Now, i have done the query.
How do i store this? I can't seem to figure it out, i want to store it in:
new OBanIP[25]; - This is at the top of the command.
+rep will be given, and i hope you can help me!
Thanks!
Posts: 508
Threads: 9
Joined: Dec 2010
Reputation:
0
EDIT: My fault i see the query already.
Posts: 6,129
Threads: 36
Joined: Jan 2009
Threads aren't required, but you can't, in SQL, select fields by using a single apostrophe, you need to use a grave (`) or none at all.
Also, make sure you use mysql_store_result() after querying, then mysql_retrieve_row() to get the specific row.
Posts: 7,801
Threads: 187
Joined: Feb 2010
Reputation:
0
Which MySQL plugin are you using?
Posts: 6,129
Threads: 36
Joined: Jan 2009
Quote:
Originally Posted by GamingTurf
Wow, thanks for all the help guys - /oban now works fine.
Butt, i've now tried making /omute, i thought i wouldn't have any problems - i was wrong:
Error:
Code:
error 035: argument type mismatch (argument 1)
Thanks, if your able to help!
I have, new IsMutedOrNot;
:S.
|
mysql_get_field probably is expecting a string as the second parameter.
pawn Code:
new szUnload[10], IsMutedOrNot;
format(checkquery, sizeof(checkquery), "SELECT `muted` FROM `users` WHERE `username` = '%s'", OBanName);
mysql_query(checkquery);
mysql_store_result();
mysql_retrieve_row();
mysql_get_field("muted", szUnload); --- Error line ----
mysql_free_result();
IsMutedOrNot = strval(szUnload);
Also, as Vince said, you can use mysql_fetch_int which would be more relevant.
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
If you're only fetching a single item from the database at a time - be it a string, integer or float - it is recommended to use mysql_fetch_row, mysql_fetch_int and mysql_fetch_float respectively.