I wasn't sure whether to post this here, to the mysql forum or to the game dev forum. I am using mysql to add and retrieve high scores from an online database in my C++ program. But whenever I try to compile I get the error "mysql_config No such file or directory" even though I cant find a reference to mysql_config anywhere in my code or headers. I have tried putting mysql_config in the folder with my .exe and it hasn't changed anything.
The section of my code that uses mysql is here:
The header for this file is:
The section of my code that uses mysql is here:
#include "getScores.h"
extern SDL_Surface *screenSurface;
extern SDL_Surface *menuBackgroundImage;
extern TTF_Font *font;
int getScores()
{
//A bunch of MySQL pointers
MYSQL *connection;
MYSQL_RES *scores;
MYSQL_ROW row; //Fight the power
//Some SDL stuff
SDL_Colour textColour = {255, 255, 255};
SDL_Surface *scoreText = NULL;
std::stringstream scoreToPrint;
//Initialize connection channel
connection = mysql_init(NULL);
//Make sure it worked
if (connection == NULL)
{
printf("Failed to initialize sql connection");
return 1;
}
//Establish connection to MySQL database and make sure it works
if (mysql_real_connect(connection, "mysql13.000webhost.com", "a9916341_40sGame",
"Cho0Cho0", "a9916341_scores", 0, NULL, 0) == NULL)
{
printf("Failed to connect to database");
return 1;
}
//Select table from database
mysql_query(connection, "SELECT * FROM highScores");
scores = mysql_store_result(connection);
//Get the data from the first 10 rows (top 10 scores)
while ((row = mysql_fetch_row(scores)))
{
for(int i = 0; i < 10; i++)
{
scoreToPrint << row[i] ? row[i] : "NULL";
scoreText = TTF_RenderText_Solid(font, scoreToPrint.str().c_str(), textColour);
}
printf("\n");
}
return 0;
}
The header for this file is:
#ifndef getScores_h #define getScores_h #include <winsock.h> #include "SDL/SDL.h" #include "SDL/SDL_ttf.h" #include "SDL/SDL_image.h" #include "mysql.h" #include <string> #include <sstream> int getScores(); #endif