raistlinmajere
Joined: 15 Feb 2006 Posts: 3
|
Posted: Sat Feb 18, 2006 16:54 Post subject: haveing a problem getting data into the database |
|
|
i am trying to get the database o recognize this
Code: |
void SetSubraceDBInt(string sCampaignName, string sVarName, int nInt, object oPlayer=OBJECT_INVALID)
{
string sPlayer;
string sTag;
if (GetIsPC(oPlayer))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oPlayer));
sTag = SQLEncodeSpecialChars(GetName(oPlayer));
}
else
{
sPlayer = "~";
sTag = GetTag(oPlayer);
}
sVarName = SQLEncodeSpecialChars(sVarName);
string sValue = IntToString(nInt);
string sSQL = "SELECT player FROM '" + SUBRACE_DATABASE + "' WHERE player='" + sPlayer +
"' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
if (SQLFirstRow() == SQL_SUCCESS)
{
sSQL = "UPDATE '" + SUBRACE_DATABASE + "' SET val='" + sValue + "',expire=0 WHERE player='"+ sPlayer + "' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
}
else
{
sSQL = "INSERT INTO '" + SUBRACE_DATABASE + "' (player,tag,name,val,expire) VALUES" +
"('" + sPlayer + "','" + sTag + "','" + sVarName + "','" + sValue + "',0)";
SQLExecDirect(sSQL);
}
}
int GetSubraceDBInt(string sCampaignName, string sVarName, object oPlayer=OBJECT_INVALID)
{
string sPlayer;
string sTag;
if (GetIsPC(oPlayer))
{
sPlayer = SQLEncodeSpecialChars(GetPCPlayerName(oPlayer));
sTag = SQLEncodeSpecialChars(GetName(oPlayer));
}
else
{
sPlayer = "~";
sTag = GetTag(oPlayer);
}
sVarName = SQLEncodeSpecialChars(sVarName);
string sSQL = "SELECT val FROM '" + SUBRACE_DATABASE + "' WHERE player='" + sPlayer + "' AND tag='" + sTag + "' AND name='" + sVarName + "'";
SQLExecDirect(sSQL);
if (SQLFirstRow() == SQL_SUCCESS)
{
return StringToInt(SQLGetData(1));
}
else
{
return StringToInt("0");
}
}
|
but in the error logs this keeps comeing back
Quote: |
o Got request: SELECT val FROM 'SUBRACE_DB' WHERE player='vendaarie' AND tag='Hastant' AND name='SBRCE_centaur'
! SQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''SUBRACE_DB' WHERE player='vendaarie' AND tag='Hastant' AND name='SBRCE_centaur'' at line 1
o Empty set |
the SUBRACE_DB is the table im useing for my subrace info its exactly the same as the pwdata from the asp_demo.mod any suggestions ? |
|