SA-MP Forums Archive
Field value from 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: Field value from mysql (/showthread.php?tid=396862)



Field value from mysql - Larry123 - 02.12.2012

Hello

I have this code:

Код:
static sql1[90];
format(sql1, sizeof(sql1), "SELECT * FROM `users` WHERE `Name` = '%s'", inputtext);
mysql_query(sql1);
mysql_store_result();
Now how can i know the same players SQLID row from users table where Name is inputtext. I have also this:

Код:
mysql_fetch_field_row(sql1, "SQLID");
SendFormatMessage(playerid, -1, "His name is: %s | His SQLID is %d", inputtext, strval(sql1));
But it don`t works, SQLID is always 0 even if player`s SQLID is really 3 or something.


Re: Field value from mysql - JJones432 - 02.12.2012

PHP код:
static sql1[90];
format(sql1sizeof(sql1), "SELECT * FROM `users` WHERE `Name` = '%s'"inputtext);
mysql_query(sql1);
mysql_store_result();
if(
mysql_retrieve_row())
{
    new 
result[50];
    
mysql_fetch_field_row(result,"SQLID");
    
SendFormatMessage(playerid, -1"His name is: %s | His SQLID is %d"inputtextstrval(result));

Should work; sql1 was the actual query, not the rows stored. Although, if you are only getting the SQLID from that query, you should use mysql_fetch_int()