Help with libmysql

I'm trying to connect to my database using the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <conio.h>
#include <math.h>
#include <cstdlib>
#include <iomanip>
#include <mysql/mysql.h>

using namespace std;

int main (){
	
    char *host = "localhost";
    char *user = "root";
    char *pass = "";
    char *db = "mdbase";

    MYSQL *sock;
    sock = mysql_init(0);
    if (sock) cout << "sock handle ok!" << endl;
    else {
         cout << "sock handle failed!" << mysql_error(sock) << endl;
    }

    if (mysql_real_connect(sock, host, user, pass, db, 0, NULL, 0))
         cout << "connection ok!" << endl;
    else {
         cout << "connection fail: " << mysql_error(sock) << endl;
    }
 		 		
 		getch ();
 		return 0;
}


But when I compile it, it results in these following errors:


57 0 c:\program files (x86)\dev-cpp\include\mysql\mysql.h In file included from c:\program files (x86)\dev-cpp\bin\../lib/gcc/mingw32/4.6.1/../../../../include/mysql/mysql.h 
6  D:\Kuliah\SI4099 - Tugas Akhir\GA CPP\Population.cpp                  from D:\Kuliah\SI4099 - Tugas Akhir\GA CPP\Population.cpp 
175 3 c:\program files (x86)\dev-cpp\include\mysql\mysql_com.h [Error] 'SOCKET' does not name a type 
339 16 c:\program files (x86)\dev-cpp\include\mysql\mysql_com.h [Error] 'SOCKET' was not declared in this scope 
339 29 c:\program files (x86)\dev-cpp\include\mysql\mysql_com.h [Error] expected primary-expression before 'const' 
339 58 c:\program files (x86)\dev-cpp\include\mysql\mysql_com.h [Error] expected primary-expression before 'unsigned' 
340 9 c:\program files (x86)\dev-cpp\include\mysql\mysql_com.h [Error] expected primary-expression before 'unsigned' 
340 29 c:\program files (x86)\dev-cpp\include\mysql\mysql_com.h [Error] expression list treated as compound expression in initializer [-fpermissive] 


Can anyone tell me whats wrong with my code??
Topic archived. No new replies allowed.