PHP Code:
public bool:OnClientConnect(id, String:szRejectMsg[], iMaxLen)
{
decl String:szAuth[36]
GetClientAuthString(id, szAuth, sizeof(szAuth))
decl String:szQuery[96]
FormatEx(szQuery, sizeof(szQuery), "SELECT * FROM spunky_db WHERE Auth=\"%s\"", szAuth)
SQL_TQuery(g_hDatabase, LoadData, szQuery, id, DBPrio_High)
return true
}
public LoadData(Handle:hOwner, Handle:hQuery, const String:szError[], any:_Data)
{
if (hQuery == INVALID_HANDLE)
{
LogError("Database failure: %s", szError)
return
}
new id = _:_Data
if (!SQL_FetchRow(hQuery))
{
LogError("Database failure: Failed to fetch initial row")
return
}
if (!SQL_GetRowCount(hQuery))
{
decl String:szAuth[36]
GetClientAuthString(id, szAuth, sizeof(szAuth))
decl String:szQuery[128]
FormatEx(szQuery, sizeof(szQuery), "INSERT INTO spunky_db VALUES (\"%s\", 1, 0, 100, 1, 0, 100)", szAuth)
SQL_TQuery(g_hDatabase, CreateData, szQuery, _, DBPrio_High)
g_iHumanLevel[id] = 1
g_iHumanExperience[id] = 0
g_iHumanMaxExperience[id] = 100
g_iZombieLevel[id] = 1
g_iZombieExperience[id] = 0
g_iZombieMaxExperience[id] = 100
return
}
g_iHumanLevel[id] = SQL_FetchInt(hQuery, 1)
g_iHumanExperience[id] = SQL_FetchInt(hQuery, 2)
g_iHumanMaxExperience[id] = SQL_FetchInt(hQuery, 3)
g_iZombieLevel[id] = SQL_FetchInt(hQuery, 4)
g_iZombieExperience[id] = SQL_FetchInt(hQuery, 5)
g_iZombieMaxExperience[id] = SQL_FetchInt(hQuery, 6)
}
Error:
Quote:
Database failure: Failed to fetch initial row
|
There are results to be fetched in the database, so I don't understand why this is happening, and the documentation is horrible at best.