MySQL Explode Reader
#1

Guys, i have been looking for some way to read from MYSQL.
And i try with explode.
The problem is When i use this code :
pawn Код:
new sscanfinput[64], string[128];
     new name[24],
      Escape[2][128];
     GetPlayerName(playerid, name, 24);
     mysql_real_escape_string(name, Escape[0]); // This function makes sure you don't get MySQL injected. Read about it by searching it on ******.
     mysql_real_escape_string(sscanfinput, Escape[1]);
     format(string, 128, "SELECT * FROM `playerinfo` WHERE user = '%s' AND password = '%s'", Escape[0], inputtext);
     mysql_query(string);
     mysql_store_result();
     if(!mysql_num_rows()) {
           mysql_free_result();
           SendClientMessage(playerid, COLOR_PURPLE, "Your password is wrong or your account doesn't exist.");
           return 1;
     }
     SendClientMessage(playerid, COLOR_PURPLE, "You're logged in.");
     new Data[80], ExplodeSplit[3][100], MyPassword[64], MyUserName[24];
     mysql_fetch_row_format(Data, "|");
     explode(ExplodeSplit, Data, "|");
     strmid(MyUserName, ExplodeSplit[0], 0, strlen(ExplodeSplit[0]), 255);
     strmid(MyPassword, ExplodeSplit[1], 0, strlen(ExplodeSplit[1]), 255);
     PlayerInfo[playerid][pLevel] = strval(ExplodeSplit[2]);
     mysql_free_result();
     return 1;
^
this code working good, but if i change it to more fields like that:

pawn Код:
new sscanfinput[64], string[128];
     new name[24],
      Escape[2][128];
     GetPlayerName(playerid, name, 24);
     mysql_real_escape_string(name, Escape[0]); // This function makes sure you don't get MySQL injected. Read about it by searching it on ******.
     mysql_real_escape_string(sscanfinput, Escape[1]);
     format(string, 128, "SELECT * FROM `playerinfo` WHERE user = '%s' AND password = '%s'", Escape[0], inputtext);
     mysql_query(string);
     mysql_store_result();
     if(!mysql_num_rows()) {
           mysql_free_result();
           SendClientMessage(playerid, COLOR_PURPLE, "Your password is wrong or your account doesn't exist.");
           return 1;
     }
     SendClientMessage(playerid, COLOR_PURPLE, "You're logged in.");
     new Data[100], ExplodeSplit[4][100], MyPassword[64], MyUserName[24];
     mysql_fetch_row_format(Data, "|");
     explode(ExplodeSplit, Data, "|");
     strmid(MyUserName, ExplodeSplit[0], 0, strlen(ExplodeSplit[0]), 255);
     strmid(MyPassword, ExplodeSplit[1], 0, strlen(ExplodeSplit[1]), 255);
     PlayerInfo[playerid][pLevel] = strval(ExplodeSplit[2]);
     PlayerInfo[playerid][pAdmin] = strval(ExplodeSplit[3]);
     mysql_free_result();
     return 1;
its not working . Like here, i just add one field and its stop to read it. What i did wrong?
Reply


Messages In This Thread
MySQL Explode Reader - by vection - 10.09.2010, 12:29
Re: MySQL Explode Reader - by vection - 10.09.2010, 17:24
Re: MySQL Explode Reader - by Vince - 10.09.2010, 18:03
Re: MySQL Explode Reader - by vection - 10.09.2010, 20:26
Re: MySQL Explode Reader - by vection - 11.09.2010, 07:54
Re: MySQL Explode Reader - by vection - 11.09.2010, 15:21

Forum Jump:


Users browsing this thread: 2 Guest(s)