Hello,
i'm very new to c++ and i'm trying to create some sql but dont really know how.
i need a very simple query in php i would do something like:
$page = "pagedata";
$sql = "INSERT INTO data SET field = '$page'";
i know i cant do it the same so i came up with the following:
string page;
char *sql;
while(!cin.eof()) page += cin.get();
sprintf(sql, "INSERT INTO data SET field = '%s';",page);
cout << sql;
mysql_query(connection, sql);
But that didnt work
so i tried:
string page,sql;
while(!cin.eof()) page += cin.get();
sql = "INSERT INTO data SET field = '" + page + "'";
cout << sql;
mysql_query(connection, sql);
This creates the query but gives a compile error:
cannot convert 'std::string' to 'const char*' for argument '2' to 'int mysql_query(MYSQL*, const char*)'
can anyone help me how to do this properly?
thanks in advance