Skocz do zawartości

  • Zaloguj korzystając z Facebooka Zaloguj korzystając z Twittera Zaloguj przez Steam Zaloguj poprzez Google      Logowanie »   
  • Rejestracja

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.

  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

[SQL] Błąd


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
Brak odpowiedzi do tego tematu

#1 daniel_bialy

    Banned

  • Zbanowany

Reputacja: 0
zer0.

  • Postów:1
  • Imię:Daniel
  • Lokalizacja:Limanowa
Offline

Napisano 30.07.2012 19:44

Yo
Otóż mam problem z zapisem SQL ponieważ wydupia błąd
[AMXX] Plugin says: 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 '' at line 1

Tutaj jest kod zapisu SQL:
//----------SQL----------//
public MySql_Init() {
  // we tell the API that this is the information we want to connect to,
// just not yet. basically it's like storing it in global variables
g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db)

// ok, we're ready to connect
new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
if(SqlConnection == Empty_Handle)
  // stop the plugin with an error message
set_fail_state(g_Error)

new Handle:Queries
// we must now prepare some random queries
new szText[128], iLen=0, iMax=sizeof(szText) - 1;
iLen += formatex(szText[iLen], iMax-iLen, "CREATE TABLE IF NOT EXISTS deathrunxpmod (steamid varchar(32), player_level INT(11), player_exp INT(11), player_sp INT(11), skill_addhp INT(11), skill_addap INT(11), skill_respawn INT(11), skill_nightmare INT(11)");
iLen += formatex(szText[iLen], iMax-iLen, ",skill_lowgravity INT(11), skill_fastrun INT(11), skill_knifer INT(11), skill_usp INT(11), skill_scount INT(11), skill_throwknife INT(11), skill_rocket INT(11), skill_mine INT(11), skill_medic INT(11)");
iLen += formatex(szText[iLen], iMax-iLen, ",skill_hegrenade INT(11), skill_smokegrenade INT(11), skill_flashgrenade INT(11))");

Queries = SQL_PrepareQuery(SqlConnection, szText)

if(!SQL_Execute(Queries))
{
  // if there were any problems the plugin will set itself to bad load.
  SQL_QueryError(Queries,g_Error,charsmax(g_Error))
  set_fail_state(g_Error)

}
// Free the querie
SQL_FreeHandle(Queries)

// you free everything with SQL_FreeHandle
SQL_FreeHandle(SqlConnection)
}
public register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) {
if(FailState == TQUERY_CONNECT_FAILED)
{
  log_amx("Load - Could not connect to SQL database.  [%d] %s", Errcode, Error)
}
else if(FailState == TQUERY_QUERY_FAILED)
{
  log_amx("Load Query failed. [%d] %s", Errcode, Error)
}
new id
id = Data[0]

if(SQL_NumResults(Query) < 1)
{
  //.if there are no results found

  new szSteamId[32]
  get_user_authid(id, szSteamId, charsmax(szSteamId)) // get user's steamid

  //  if its still pending we can't do anything with it
  if (equal(szSteamId,"ID_PENDING"))
   return PLUGIN_HANDLED

  new szTemp[512]

  // now we will insturt the values into our table.
  format(szTemp,charsmax(szTemp),"INSERT INTO `deathrunxpmod` ( `steamid` , `player_level` , `player_exp`, `player_sp`, \
  `skill_addhp`, `skill_addap`, `skill_respawn`, `skill_nightmare`, `skill_lowgravity`, `skill_fastrun`, `skill_knifer`, \
  `skill_usp`, `skill_scount`, `skill_throwknife`, `skill_rocket`, `skill_mine`, `skill_medic`, `skill_hegrenade`, `skill_smokegrenade`, \
  `skill_flashgrenade`) VALUES ('%s','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0');",szSteamId)
  SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
}
else
{
  // if there are results found
  player_level[id]		 = SQL_ReadResult(Query, 1)
  player_exp[id]		 = SQL_ReadResult(Query, 2)
  player_sp[id]		 = SQL_ReadResult(Query, 3)
  skill_addhp[id]		 = SQL_ReadResult(Query, 4)
  skill_addap[id]		 = SQL_ReadResult(Query, 5)
  skill_respawn[id]		 = SQL_ReadResult(Query, 6)
  skill_nightmare[id]		 = SQL_ReadResult(Query, 7)
  skill_lowgravity[id]		 = SQL_ReadResult(Query, 8)
  skill_fastrun[id]		 = SQL_ReadResult(Query, 9)
  skill_knifer[id]		 = SQL_ReadResult(Query, 10)
  skill_usp[id]		 = SQL_ReadResult(Query, 11)
  skill_scount[id]		 = SQL_ReadResult(Query, 12)
  skill_throwknife[id]		 = SQL_ReadResult(Query, 13)
  skill_rocket[id]		 = SQL_ReadResult(Query, 14)
  skill_mine[id]		 = SQL_ReadResult(Query, 15)
  skill_medic[id]		 = SQL_ReadResult(Query, 16)
  skill_hegrenade[id]		 = SQL_ReadResult(Query, 17)
  skill_smokegrenade[id]		 = SQL_ReadResult(Query, 18)
  skill_flashgrenade[id]		 = SQL_ReadResult(Query, 19)
}
return PLUGIN_HANDLED
}
public Save_MySql(id){
new szSteamId[32], szTemp[512]
get_user_authid(id, szSteamId, charsmax(szSteamId))

// Here we will update the user hes information in the database where the steamid matches.
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `player_level` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", player_level[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `player_exp` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", player_exp[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `player_sp` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", player_sp[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_addhp` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_addhp[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_addap` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_addap[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_respawn` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_respawn[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_nightmare` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_nightmare[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_lowgravity` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_lowgravity[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_fastrun` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_fastrun[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_knifer` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_knifer[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_usp` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_usp[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_scount` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_scount[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_throwknife` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_throwknife[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_rocket` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_rocket[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_mine` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_mine[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_medic` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_medic[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_hegrenade` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_hegrenade[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_smokegrenade` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_smokegrenade[id], szSteamId)
format(szTemp,charsmax(szTemp),"UPDATE `deathrunxpmod` SET `skill_flashgrenade` = '%i' WHERE `deathrunxpmod`.`steamid` = '%s';", skill_flashgrenade[id], szSteamId)
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
}
public Load_MySql(id) {
new szSteamId[32], szTemp[512]
get_user_authid(id, szSteamId, charsmax(szSteamId))

new Data[1]
Data[0] = id

//we will now select from the table `tutorial` where the steamid match
format(szTemp,charsmax(szTemp),"SELECT * FROM `deathrunxpmod` WHERE (`deathrunxpmod`.`steamid` = '%s')", szSteamId)
SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
}
//----------SQL----------//

Proszę o pomoc




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych