extern MYSQL *database;
MYSQL *database;
void init_mysql (void)
{
database = mysql_init (database);
if ( !(mysql_real_connect (database, MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASS, PRIMARY_DATABASE, 0, NULL, 0)) )
fprintf(stderr, "Fatal Error: %s\n", mysql_error(database));
abort();
system_log ("MySQL connection initialized.", FALSE);
}
This is the code where its failing. The problem im really having is when it aborts its not giving me why, so im left with nothing to try to figure out. The MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASS, and PRIMARY_DATABASE are all defined in structs.h and shouldnt be the problem i dont think, since if i try to use a login that wont work, it will give an error, so im assuming the user and pass im giving work fine. Running this on redhat 9 with mysql 4.0. Hope someone can help or give me a pointer, been trying to get this MUD to run for a while now and no luck.
Problem with mysql
Having a little problem here. I downloaded a MUD codebase recently that uses mysql and have been trying to get it working. Problem is when i try to start the MUD, it just aborts, and all i know is its aborting trying to connect to mysql.
there could be a lot of reasons its failing.... just to be sure, you DO have a MySQL database setup somewhere, right?
I think I see where the problem is...
You write if (mysql_real_connect(...))
fprintf();
abort();
but you forgot the brackets! You should have written
Without the brackets the abort() function will be called every time even if the connection doesn't fail.
Quote:Original post by Talithif ( !(mysql_real_connect (database, MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASS, PRIMARY_DATABASE, 0, NULL, 0)) ) fprintf(stderr, "Fatal Error: %s\n", mysql_error(database));HERE --> abort();
You write if (mysql_real_connect(...))
fprintf();
abort();
but you forgot the brackets! You should have written
if (mysql_real_connect(...)){ fprintf(); abort();}
Without the brackets the abort() function will be called every time even if the connection doesn't fail.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement