Advertisement
Guest User

Untitled

a guest
May 5th, 2014
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include "StdAfx.h"
  2. #include "FuSIONMySQL.h"
  3. #include <stdlib.h>
  4. #include <iostream>
  5. #include <cstdio>
  6. #include <cstdlib>
  7. #include "ServerFunctions.h"
  8.  
  9. /*
  10. Include directly the different
  11. headers from cppconn/ and mysql_driver.h + mysql_util.h
  12. (and mysql_connection.h). This will reduce your build time!
  13. */
  14.  
  15. // For MySQL Connection
  16. #include <mysql.h>
  17.  
  18. using namespace std;
  19.  
  20. // Defining Constant Variables
  21. #define SERVER "database.crysiswars.zyboxgaming.eu"
  22. #define USER "[classified]"
  23. #define PASSWORD "[classified]"
  24. #define DATABASE "[classified]"
  25.  
  26. void FuSIONConnect()
  27. {
  28.     MYSQL *connect;
  29.     connect = mysql_init(NULL);
  30.  
  31.     if (!connect)
  32.     {
  33.         GF_Log("Failed to initialize FuSION Database connection", false);
  34.     }
  35.  
  36.     connect = mysql_real_connect(connect, SERVER, USER, PASSWORD, DATABASE, 0, NULL, 0);
  37.  
  38.     if (connect)
  39.     {
  40.         GF_Log("Connected to FuSION Database", false);
  41.     }
  42.     else
  43.     {
  44.         GF_Log("Failed to initialize FuSION Database connection", false);
  45.     }
  46.  
  47.     MYSQL_RES *res_set;
  48.     MYSQL_ROW row;
  49.  
  50.     // Replace MySQL query with your query
  51.  
  52.     mysql_query(connect, "show tables");
  53.  
  54.     unsigned int i = 0;
  55.  
  56.     res_set = mysql_store_result(connect);
  57.  
  58.     unsigned int numrows = mysql_num_rows(res_set);
  59.  
  60.     cout << " Tables in " << DATABASE << " database " << endl;
  61.  
  62.     while (((row = mysql_fetch_row(res_set)) != NULL))
  63.     {
  64.         cout << row[i] << endl;
  65.     }
  66.  
  67.     mysql_close(connect);
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement