Hi pals,
I try a code in my Dev -C++
Environment v 4.9.9.2 in Windows XP. I save file as "satwant_mysql.cpp"
in E:/C++/ Directory....

#include <mysql/mysql.h>
    #include <stdio.h>
   
   int main(){
   
     MYSQL mysql;
      MYSQL_ROW row;
     MYSQL_RES *result;
     
     unsigned int num_fields;
     unsigned int i;
  
     mysql_init(&mysql);
  
     if (!mysql_real_connect(&mysql,"localhost","root","","MyDatabase",0,NULL,0))
     {
      fprintf(stderr, "Failed to connect to database: Error: %s\n",
         mysql_error(&mysql));
     }
     else {
      if(mysql_query(&mysql, "SELECT * FROM my_table"));
        //here goes the error message <!-- s:o --><img 

src=\"{SMILIES_PATH}/icon_surprised.gif\" alt=\":o\" title=\"Surprised\"><!-- s:o 

-->)
      else {
        result = mysql_store_result(&mysql);
        num_fields = mysql_num_fields(result);
       while ((row = mysql_fetch_row(result)))
        {
           unsigned long *lengths;
           lengths = mysql_fetch_lengths(result);
           for(i = 0; i < num_fields; i++)
          {
               printf("[%.*s] \t", (int) lengths[i], row[i] ? row[i] : "NULL");
           } 
           printf("\n");
        }
      }
     }
  
     return 0;
  
   }

I got Error As:

In file included from D:/Installations/wxDev-Cpp/include/mysql/mysql.h:57,
                 from E:\C++\satwant_mysql.cpp:1:
D:/Installations/wxDev-Cpp/include/mysql/mysql_com.h:175: error: `SOCKET' does not 

name a type
D:/Installations/wxDev-Cpp/include/mysql/mysql_com.h:339: error: `SOCKET' was not 

declared in this scope
D:/Installations/wxDev-Cpp/include/mysql/mysql_com.h:339: error: expected 

primary-expression before "const"
D:/Installations/wxDev-Cpp/include/mysql/mysql_com.h:339: error: expected 

primary-expression before "unsigned"
D:/Installations/wxDev-Cpp/include/mysql/mysql_com.h:340: error: expected 

primary-expression before "unsigned"
D:/Installations/wxDev-Cpp/include/mysql/mysql_com.h:340: error: initializer 

expression list treated as compound expressionExecution terminated

I Install my application(Dev-C++) in D:/Installations/wxDev-Cpp/.

How it can avoid , pls Advise me.

Regards
Anes P.A

Include <windows.h>

#include <windows.h>
#include <mysql/mysql.h>
...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.