Hi there,

here what my problem is - I'm trying to get data from MySQL database put in on global array and make calculation. The data in the MySQL table is 3000 rows and 2 columns. The type of data is double and date

Here is the code:

#include <stdlib.h>
#include <iostream>
#include <mysql.h>
#include <stdio.h>

MYSQL conn;
MYSQL_RES *res;
MYSQL_ROW msq_row;

int main()
{

    double mysql_result[3000][2];
    int i;
    int j;
    int history=3000;

  
    mysql_init(&conn);
    mysql_real_connect(&conn, "localhost", "root", "1a2s3d", "portfolio", 0, NULL, 0);

    mysql_query(&conn, "SELECT date, close from quotes where companyID=1");

    res=mysql_use_result(&conn);

  

    for (j=0;j=history;j++)
    {
            for (i=0;i=mysql_num_fields(res);i++)
            {
                
                msq_row=mysql_fetch_row(res);
                mysql_result[3000][2]=msq_row;
                printf("%d\n",msq_row[i]);
          
            }
    }
    mysql_free_result(res);
    mysql_close(&conn);
     


    return (EXIT_SUCCESS);
}

the cygwin g++ compiler give this:

/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'
/usr/bin/make -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin-Windows/pordotovka.exe
make[2]: Entering directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'
mkdir -p build/Debug/Cygwin-Windows
rm -f build/Debug/Cygwin-Windows/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/Cygwin-Windows/main.o.d -o build/Debug/Cygwin-Windows/main.o main.cpp
main.cpp: In function `int main()':
main.cpp:45: error: cannot convert `char**' to `double' in assignment
make[2]: *** [build/Debug/Cygwin-Windows/main.o] Error 1
make[2]: Leaving directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/cygdrive/c/Program Files/MyPrograms/Apache/htdocs/QuadProg++/Pordotovka'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 828ms)

Please give me gleam ... thank you

>>mysql_result[3000][2]=msq_row;

If you programmed the rest of that then you should probably know that the above like doesn't work. You should be reading this tutorial. (scroll down to the section Retrieving data from the database)

the indexes are there because I try some changes and after their failure a copy from declaration is pasted. However I will read the tutorial, but if you have any suggestions .... thank you

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.