Register
#1

PHP код:
//OnAccount check
ShowPlayerDialog(playeriddREGISTERDIALOG_STYLE_INPUT"Register""Welcome To ZoneX your Username is not founded in our Database Please Register.""Register""Quit");
On Dialog Response
        
case dREGISTER//register dialog
        
{
            if(!
response) return Kick(playerid); //if they clicked Quit, we will kick them
            
if(strlen(inputtext) < 6) return ShowPlayerDialog(playeriddREGISTERDIALOG_STYLE_INPUT"Register""In order to play, you need to register.\nYour password must be at least 6 characters long!""Register""Quit");
            
//strlen checks a lenght of a string. so if player types their password that is lower than 6, we tell them; Your password must be at least 6 characters long!
                
WP_Hash(pData[playerid][Password], 129inputtext); //hashing inputtext
                
new Msg[130], str[800];
                
pData[playerid][ID] = cache_insert_id(); //loads the ID of the player in the variable once they registered.
                
printf("New account registered. ID: %d"pData[playerid][ID]); //just for debugging.
                
pData[playerid][Money] = 50000;
                
GivePlayerMoney(playerid50000);
                
format(strsizeof(str), "INSERT INTO `players`(`ID`, `Username`, `Password`, `IP`, `Admin`, `VIP`, `Kills`, `Cookies`, `Cakes`, `Icecream`, `Deaths`, `Score`, `Money`, `Hours`, `Minutes`) VALUES ('%d','%s','%s','%s',0,0,0,0,0,0,0,0,0,0,0)"pData[playerid][ID], GetName(playerid), pData[playerid][Password], IP[playerid]);
                
mysql_query(mysqlstr);
                
format(joinMsgsizeof(joinMsg), "02[%d] 03*** 11,12* Player %s has registered new at ZoneX (Zx)",playeridGetName(playerid));
                
IRC_GroupSay(groupIDIRC_CHANNELjoinMsg);
                new 
rowsCache:getCache;
                
getCache mysql_query(mysql"SELECT * FROM `players`");
                
cache_get_row_count(rows);
                
format(Msgsizeof(Msg), "{00FF50}%s has registered at ZX {FF0000}[Total Registered Players: %i]",GetName(playerid), rows);
             
SendClientMessageToAll(playerid,Msg);
             
pData[playerid][Admin] = 1;
             
pData[playerid][RaceWon] = 0;
              
cache_delete(getCache);
            
//let's execute the query
        

When a player register it doesn't insert name, data in players database
Reply
#2

Obviously you can't get the insert_id before the actual insert takes place. That's the point. It is the insert statement that generates the ID. This function merely returns that value. If the ID column is set to auto_increment then you can leave it out of the query. Alternatively you can specify the value as null, default or 0.

Also NEVER use row_count if the only thing you're interested in is a count of something. That is terribly inefficient. Use the aggregate COUNT() function. This always returns exactly one row and one column with the value being the count.

Check the logs as well.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Obviously you can't get the insert_id before the actual insert takes place. That's the point. It is the insert statement that generates the ID. This function merely returns that value. If the ID column is set to auto_increment then you can leave it out of the query. Alternatively you can specify the value as null, default or 0.

Also NEVER use row_count if the only thing you're interested in is a count of something. That is terribly inefficient. Use the aggregate COUNT() function. This always returns exactly one row and one column with the value being the count.

Check the logs as well.
I don't understand can you solve and send me solve?
Reply
#4

help?
Reply
#5

bumb
Reply
#6

That code every one register it give him same id is -1
Reply
#7

Show your log mysql please
Reply
#8

You do not deserve a help if you don't even know a single bit of MySQL, go and start off with SQLite.
Reply
#9

Quote:
Originally Posted by JaKe Elite
Посмотреть сообщение
You do not deserve a help if you don't even know a single bit of MySQL, go and start off with SQLite.
I know mysql and iam learning + If you don't have some thing good to say so shut up + Fixed
Reply
#10

Quote:
Originally Posted by Vince
Посмотреть сообщение
you can't get the insert_id before the actual insert takes place
Take specific notice of the words "can't" and "before". What would be the logical thing to do then? Invert the statement: you can get the insert_id after the actual insert takes place.

I'm severely allergic to bumps that provide no additional information because then it appears to me that the person that asked the question is merely waiting for a response without having tried anything else in the meantime.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)