SA-MP Forums Archive
help with mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help with mysql (/showthread.php?tid=477738)



help with mysql - Gafsi - 26.11.2013

hello im trying to making register and login system with mysql but its not save anythig even if the name registered hes show me the register dialog again!!


pawn Код:
public OnPlayerConnect(playerid)
{
  new query[126], pName[MAX_PLAYER_NAME];
  GetPlayerName(playerid, pName,sizeof (pName));
  format(query,sizeof (query),"SELECT * FROM `users` WHERE `Username` = '%s'",pName);
  mysql_query(query);
  mysql_store_result();
  if(mysql_num_rows() == 1)
  {
    ShowPlayerDialog(playerid, 16, DIALOG_STYLE_INPUT, "Login","please ENTER your password for login to your account","Login","Close");
  }
  else
  {
     ShowPlayerDialog(playerid, 17, DIALOG_STYLE_INPUT, "Register","please ENTER your password for register a new game account","Register","Close");
  }
  return 1;

}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

   switch(dialogid)
   {
      case 0:
      {
          if(response)
          {
              new query[200], pName[MAX_PLAYER_NAME];
              GetPlayerName(playerid, pName,sizeof (pName));
              format(query,sizeof(query),"SELECT * FROM `users` WHERE `Username` = '%s' AND `Password` = '%s'", pName, inputtext);
              mysql_query(query);
              mysql_store_result();
             
              if(mysql_num_rows() == 1)
              {
             
                 SendClientMessage(playerid, COLOR_ROZZ, "You have logged in!");
                 SetSpawnInfo(playerid, 0, 0, 1682.7000, -2244.8999, 13.5454, 178.9000, 22, 50, 0, 0, 0, 0);
                 SpawnPlayer(playerid);
              }
              else
              {
             
                 SCM(playerid, RED, "Wrong Password");
                 ShowPlayerDialog(playerid, 16, DIALOG_STYLE_INPUT, "Login","please ENTER your password for login to your account","Login","Close");
              }
          }
      }
      case 1:
      {
     
         if(response)
         {
         
             new query[200], pName[MAX_PLAYER_NAME];
             GetPlayerName(playerid, pName,sizeof (pName));
             format(query,sizeof(query),"INSERT INFO `users` VALUES ('%s', '%s')",pName, inputtext);
             mysql_query(query);
             
             SendClientMessage(playerid, COLOR_ROZZ, "Thanks for registering! have a lot of fun!.");
             SetSpawnInfo(playerid, 0, 0, 1682.7000, -2244.8999, 13.5454, 178.9000, 22, 50, 0, 0, 0, 0);
             SpawnPlayer(playerid);
             
         }
      }
   
   }
   return 1;
}




Re: help with mysql - iJumbo - 26.11.2013

You writed INSERT INFO while its INSERT INTO