mysql help
#1

Hello,

I want to check some variable and if X variable= ... update. I use while(mysql_retrieve_row(). In the debug it work's, but the update don't work. Thanks.

Код:
format(query,sizeof(query),"SELECT `Name`, `Level` FROM `players` WHERE `Active`=0");
mysql_query(query);
mysql_store_result();
while(mysql_retrieve_row()) // or other?
{
    new str[11];
    new pname[26];
    new pname2[26];
    new lvl;
    mysql_fetch_field_row(str, "Level"); lvl = strval(str);
    mysql_fetch_field_row(pname, "Name"); strmid(pname2,pname, 0, strlen(pname), 26);
    printf("%s",pname2);
    if( lvl< 16) //don't work
   {
	format(query,sizeof(query),"UPDATE `players` SET `Level` = 1 WHERE `Name` = '%s'",pname2);
        //remove file with pname2
   }
}
...
Reply
#2

I don't see exactly why you need the select statement at all.

pawn Код:
mysql_query("UPDATE `players` SET `Level` = 1 WHERE Active = 0 AND Level < 16");
That would do the exact same thing. I also don't see why you use pname2 as you can just fetch the name into pname and it would be the exact same.
Reply
#3

nevermind
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)