469,923 Members | 1,745 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

mysql_real_connect problem!

Hi All

Iam using the libmysql.lib in my C++ app, I have a mySQL database setup on a
remote server something.dyndns.org and using port 2000, I use the following
little bit of code to try and access the database but it just sits there and
does nothing. Iam I doing something wrong, not doing something or is there a
problem using libmysql with a C++ app. Any help would be great.

#include <windows.h>
#include <winsock2.h>

#pragma warning (disable: 4514 4786)
#pragma warning( push, 3 )
#define VERSION "4.1"
#endif

#pragma comment(lib, "libmysql.lib")

// SQL test
#include <MySQL.h>

void MySQLTest(void)
{
MYSQL *mysql = NULL;
MYSQL *connect = NULL;
//int timeout = 4;

mysql = mysql_init(NULL);

//mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&timeout);

connect = mysql_real_connect(mysql, "something.dyndns.org", "root", NULL,
"mysql", 2000, NULL, 0);

if ( !connect )
{
// Had a problem
Debug(("Failed to connect to database: Error: %s<br>\n",
mysql_error(mysql)));
}
else
{
Debug(("We connected to the SQL database<br>\n"));
}

mysql_close(mysql);
}

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.648 / Virus Database: 415 - Release Date: 31/03/2004
Jul 19 '05 #1
2 5032
Jasper wrote:
mysql = mysql_init(NULL);


I don't bulieve the problem is here, but you should check the return
value from mysql_init to make sure it is not NULL (which means error).
Jul 19 '05 #2
Jasper wrote:
mysql = mysql_init(NULL);


I don't bulieve the problem is here, but you should check the return
value from mysql_init to make sure it is not NULL (which means error).
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Bruce Davis | last post: by
11 posts views Thread by Kostatus | last post: by
1 post views Thread by Jasper | last post: by
117 posts views Thread by Peter Olcott | last post: by
1 post views Thread by Chinmay Shah | last post: by
28 posts views Thread by Jon Davis | last post: by
6 posts views Thread by Ammar | last post: by
2 posts views Thread by Mike Collins | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.