prøvede med flg.
#include <stdio.h>
#include <mysql.h>
#define host "localhost"
#define username "db_username"
#define password "db_password"
#define database "db"
MYSQL *conn;
int main()
{
conn = mysql_init(NULL);
mysql_real_connect(conn,host,username,password,database,0,NULL,0);
MYSQL_RES *res_set;
MYSQL_ROW row;
unsigned int i;
mysql_query(conn,"SELECT * FROM users WHERE userid=1");
res_set = mysql_store_result(conn);
unsigned int numrows = mysql_num_rows(res_set);
while ((row = mysql_fetch_row(res_set)) != NULL)
{
for (i=0; i<mysql_num_fields(res_set); i++)
{
printf("%s\\n",row[i] != NULL ? row[i] : "NULL");
}
}
mysql_close(conn);
return 0;
}
men er helt lost med dette.. forstå det altså ikke.. får flg fejl.. mangler en masse, men håber nogle har tid til en gang at sætte mig lidt ind i det.. for fatter det, gør jeg slet ikke
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\\Documents and Settings\\refugedk\\Desktop\\CPP\\da\\lol.cpp" -o "C:\\Documents and Settings\\refugedk\\Desktop\\CPP\\da\\lol.exe" -g3 -I"C:\\Dev-Cpp\\include\\c++" -I"C:\\Dev-Cpp\\include\\c++\\mingw32" -I"C:\\Dev-Cpp\\include\\c++\\backward" -I"C:\\Dev-Cpp\\include" -L"C:\\Dev-Cpp\\lib"
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:2:20: mysql.h: No such file or directory
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:9: syntax error
before `*' token
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp: In function `int
main()':
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:13: `conn' undeclared
(first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:13: (Each undeclared
identifier is reported only once for each function it appears in.)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:13: `mysql_init'
undeclared (first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:14: `
mysql_real_connect' undeclared (first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:15: `MYSQL_RES'
undeclared (first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:15: `res_set'
undeclared (first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:16: `MYSQL_ROW'
undeclared (first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:16: parse error
before `;' token
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:18: `mysql_query'
undeclared (first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:19: `
mysql_store_result' undeclared (first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:20: `mysql_num_rows'
undeclared (first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:21: `row' undeclared
(first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:21: `mysql_fetch_row'
undeclared (first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:23: `
ltmysql_num_fields' undeclared (first use this function)
C:/Documents and Settings/refugedk/Desktop/CPP/da/lol.cpp:28: `mysql_close'
undeclared (first use this function)
Execution terminated