[MySQL] Error (0): Failed to exeute query. Column count doesn't match value count at row 1.
#1

PHP Code:
stock MySQL_Login(playerid)
{
    new 
Query[500];
    
mysql_real_escape_string(pInfo[playerid][Nick], pInfo[playerid][Nick]); // escaping the name of the player to avoid sql_injections.
    
format(Querysizeof(Query), "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s' LIMIT 1"pInfo[playerid][Nick]);
    
mysql_query(Query);
    
mysql_store_result();
    while(
mysql_fetch_row(Query))
    {
        
mysql_fetch_int("id"pInfo[playerid][ID]);
        
mysql_fetch_int("admin"pInfo[playerid][pAdmin]);
        
mysql_fetch_int("helper"pInfo[playerid][pHelper]);
        
mysql_fetch_int("moderator"pInfo[playerid][pMod]);
        
mysql_fetch_int("score"pInfo[playerid][pScore]); SetPlayerScore(playeridpInfo[playerid][pScore]);
        
mysql_fetch_int("money"pInfo[playerid][pMoney]); GivePlayerMoney(playeridpInfo[playerid][pMoney]);
        
mysql_fetch_int("gold"pInfo[playerid][Gold]);
        
mysql_fetch_int("kills"pInfo[playerid][pKills]);
        
mysql_fetch_int("deaths"pInfo[playerid][pDeaths]);
        
mysql_fetch_int("PosX"pInfo[playerid][PosX]);
        
mysql_fetch_int("PosY"pInfo[playerid][PosY]);
        
mysql_fetch_int("PosZ"pInfo[playerid][PosZ]);
        
mysql_fetch_int("kicks"pInfo[playerid][kicks]);
        
mysql_fetch_int("bans"pInfo[playerid][bans]);
        
mysql_fetch_int("banned"pInfo[playerid][pBanned]);
        
mysql_fetch_int("playinghours"pInfo[playerid][PlayingHours]);
        
mysql_fetch_int("adminhelp"pInfo[playerid][AdminHelp]);
         
mysql_fetch_int("experiencepoints"pInfo[playerid][ExperiencePoints]);
         
mysql_fetch_int("experiencepointsneeded"pInfo[playerid][ExperiencePointsNeeded]);
        
mysql_fetch_int("secondslogged"pInfo[playerid][SecondsLoggedIn]);
        
    }
    
mysql_free_result();
    
// here we free our result and end the SELECT process.
    
pInfo[playerid][Logged] = 1// sets the logged variable to 1 meaning logged in.
    
return 1;
}
SavePlayer(playerid)
{
    if(
pInfo[playerid][Logged] == 1)
    {
        new 
Query[500];
        
format(Query500"UPDATE `playerdata` SET `admin` = %d, `helper` = %d, `moderator` = %d, `score` = %d, `money` = %d, `kills` = %d, `deaths` = %d, `experiencepoints` = %d, `experiencepointsneeded` = %d, `PosX` = %d, `PosZ` = %d, `PosY` = %d, `kicks` = %d, `bans` = %d, `banned` = %d, `playinghours`= %d, `secondslogged` = %d, `adminhelp` = %d, WHERE `id` = %d",
        
pInfo[playerid][pAdmin],
        
pInfo[playerid][pHelper],
        
pInfo[playerid][pMod],
        
pInfo[playerid][pScore],
        
pInfo[playerid][pMoney],
        
pInfo[playerid][pKills],
        
pInfo[playerid][pDeaths],
        
pInfo[playerid][ExperiencePoints],
        
pInfo[playerid][ExperiencePointsNeeded],
          
pInfo[playerid][PosX],
        
pInfo[playerid][PosZ],
        
pInfo[playerid][PosY],
        
pInfo[playerid][kicks],
        
pInfo[playerid][bans],
        
pInfo[playerid][pBanned],
        
pInfo[playerid][PlayingHours],
        
pInfo[playerid][SecondsLoggedIn],
        
pInfo[playerid][AdminHelp],
        
pInfo[playerid][ID]);
        
mysql_query(Query);
    }

pawn Code:
[02:43:34] [MySQL] Error (0): Failed to exeute query. Column count doesn't match value count at row 1.
[02:43:42] [MySQL] Error (0): Failed to exeute query. 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 '
WHERE `id` = 0' at line 1.
PHP Code:
CREATE TABLE IF NOT EXISTS `playerdata` (
  `
nickvarchar(255NOT NULL,
  `
passwordvarchar(255NOT NULL,
  `
ipvarchar(15NOT NULL,
  `
adminint(10NOT NULL DEFAULT '0',
  `
helperint(10NOT NULL DEFAULT '0',
  `
moderatorint(10NOT NULL DEFAULT '0',
  `
scoreint(15NOT NULL DEFAULT '0',
  `
moneyint(15NOT NULL DEFAULT '0',
  `
killsint(15NOT NULL DEFAULT '0',
  `
deathsint(15NOT NULL DEFAULT '0',
  `
experiencepointsint(15NOT NULL DEFAULT '0',
  `
experiencepointsneededint(15NOT NULL DEFAULT '0',
  `
PosXfloat NOT NULL,
  `
PosZfloat NOT NULL,
  `
PosYfloat NOT NULL,
  `
kicksint(15NOT NULL DEFAULT '0',
  `
bansint(15NOT NULL DEFAULT '0',
  `
bannedint(15NOT NULL DEFAULT '0',
  `
playinghoursint(15NOT NULL DEFAULT '0',
  `
secondsloggedvarchar(15NOT NULL DEFAULT '0',
  `
adminhelpint(15NOT NULL DEFAULT '0',
  `
idint(15NOT NULL
ENGINE=InnoDB DEFAULT CHARSET=latin1
Whats wrong?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)