19.05.2015, 23:47
You should really set all columns in which you want to store a 0 (as in your extremely long query) to have a default value of "0" using a tool that can browse your mysql tables (like Navicat).
That will shorten your query alot and you will find mistakes alot easier.
Your query could be reduced to:
All other fields don't need to be inserted into your query if you set all those columns to default value of 0, because mysql will fill them in by itself if not supplied.
Note that the length of the query went from 750 to 160 (the maximim size of characters that would ever be inserted into the query: 24 chars for the name, 16 for the IP and 40 for the SHA1 hash).
That's about 1/5th the size of the original query, and does exactly the same thing when someone registers a new account.
Your actual problem was that you were mixing up both strings:
It should be:
You were only sending the second part (starting from VALUES ...), instead of the merged query, which is stored into "string".
That will shorten your query alot and you will find mistakes alot easier.
Your query could be reduced to:
PHP код:
format(query1, 160, "INSERT INTO `players` (`username`, `password`, `IP`) VALUES('%s', SHA1('%s'), '%s')", GetName(playerid), passwordstring, pInfo[playerid][pIP]);
Note that the length of the query went from 750 to 160 (the maximim size of characters that would ever be inserted into the query: 24 chars for the name, 16 for the IP and 40 for the SHA1 hash).
That's about 1/5th the size of the original query, and does exactly the same thing when someone registers a new account.
Your actual problem was that you were mixing up both strings:
PHP код:
strcat(string, query1);
mysql_query(query1);
PHP код:
strcat(string, query1);
mysql_query(string);