Hey everyone,
I been mucking around with mysql and ue4 yesterday and ive got my database connected etc, I have a register page at the moment, after I put in 1 lot of username and password combos I cannot change it again, it is changing through my blueprint that connects to it but not in the c++ side of things.
My .cpp
void UBP_Database_Connect::RegisterUser(FString un, FString pw)
{
#define dbHOST "tcp://127.0.0.1:3306"
#define dbUSER "root"
#define dbPASS ""
#define dbDB "test"
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
sql::PreparedStatement *pstmt;
static string UN(TCHAR_TO_UTF8(*un));
static string PW(TCHAR_TO_UTF8(*pw));
driver = get_driver_instance();
con = driver->connect(dbHOST, dbUSER, dbPASS);
stmt = con->createStatement();
stmt->execute("USE " dbDB);
res = stmt->executeQuery("SELECT (id) FROM test");
int id = res->rowsCount() + 1;
delete res;
delete stmt;
pstmt = con->prepareStatement("INSERT INTO test(id,username,password) VALUES (?,?,?)");
pstmt->setInt(1, id);
pstmt->setString(2, UN);
pstmt->setString(3, PW);
pstmt->executeUpdate();
delete pstmt;
delete con;
}
catch (sql::SQLException)
{
}
}
my .h
UFUNCTION(BlueprintCallable, Category = "DB")
static FString RegisterUser(FString un, FString pw);
Any my bueprints
any help will be much appreciated