#include <unistd.h> char * getpass(const char * prompt)
CXXFLAGS = `mysql_config --include` LDLIBS = `mysql_config --libs`
#include <my_global.h> #include <mysql.h>
if (NULL == mysql_real_connect(conn, "", "", password.c_str(), "dbennett", 0, NULL, 0)) { cout << "Connection Failed: " << endl; cout << mysql_error(conn) << endl; return -1; }
command = "select * from EQUIPMENT"; if (!mysql_query(conn, command.c_str())) { cout << "Query failed: " << endl; cout << mysql_error(conn) << endl; return -1; }
queryResult = mysql_store_result(conn); if (queryResult == NULL) { ... } ... mysql_free_result(queryResult);
fieldCount = mysql_num_fields(queryResult); cout << "There are " << fieldCount << " fields in the result." << endl; while ((aRow = mysql_fetch_row(queryResult)) != NULL) { for(int i =0;i<fieldCount; i++) { if (aRow[i] !=NULL) { cout << aRow[i] << " "; } } cout << endl; }