Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <mysql.h>
#include <iostream>
#include <string>
using namespace std;
int qstate;
int main() {
MYSQL* conn;
MYSQL_ROW row;
MYSQL_RES *res;
conn = mysql_real_connect(conn, "localhost", "root", "password", "gamedb", 3306, NULL, 0);
if (conn) {
puts("Connected to Database!");
string query = "SELECT FROM game";
const char* q = query.c_str();
qstate = mysql_query(conn, q);
if (!qstate)
{
res = mysql_store_result(conn);
while (row = mysql_fetch_row(res)) {
cout << ("ID: %s, Name: %s, Pokemons: %s\n", row[0], row[1], row[2]) << endl;
}
}
else {
cout << "Connection Failed: " << mysql_error(conn) << endl;
}
}
else {
puts("Couldn't Connect to Database.");
}
return 0;