daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public OnFilterScriptInit()
  2. {
  3.     new somevar = 1337;
  4.     mysql_debug(1);
  5.         new con = mysql_connect(host, user, db, pass);
  6.     // Table structure:  id|username|pass|money
  7.     format(string, sizeof string, "SELECT * FROM `users`");
  8.     mysql_function_query(con, string, true, "Test", "i", somevar);
  9.     return 1;
  10. }
  11.  
  12. public Test(somevar)
  13. {
  14.     new rows, fields, szRow[128];
  15.     cache_get_data(rows, fields);
  16.     for(new i;i < rows;i++) {
  17.         szRow = fetch_field_content("username", i, fields);
  18.         printf("Username = %s", szRow);
  19.         szRow = fetch_field_content("money", i, fields);
  20.         printf("Username = %s", szRow);
  21.     }
  22.     // returning 1 at the end means the cache & memory will be automatically free'd
  23.     return 1;
  24. }  
  25.  
  26. // mysql_fetch_field_row() alias
  27. stock fetch_field_content(fieldname[], row, fields)
  28. {
  29.     new szField[40], szRow[128];
  30.     for(new i;i < fields;i++) {
  31.         cache_get_field(i, szField);
  32.         if(!strcmp(szField, fieldname)) {
  33.             cache_get_row(row, i, szRow);
  34.             break;
  35.         }
  36.     }
  37.     return szRow;
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top