Jump to content
  • Advertisement
Sign in to follow this  
Talith

Problem with mysql

This topic is 4947 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.
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.

Share this post


Link to post
Share on other sites
Advertisement
I think I see where the problem is...
Quote:
Original post by Talith

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));
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!