28.02.2017, 13:27
Hi guys, I'm learning MySQL and I get this error. I'm doing a registration system with MySQL to save the player data. But the problem is when the player register, it doesn't insert anything to my database.
PHP Code:
new pName[MAX_PLAYER_NAME], query[256];
GetPlayerName(playerid, pName, sizeof(pName));
mysql_format(MHandle, query, sizeof(query), "SELECT * FROM `character` WHERE `Username` = '%e' LIMIT 1", pName);
mysql_query(MHandle, query);
new rows;
cache_get_row_count(rows);
if(!rows){
System_Scm(playerid, COLOR_YELLOW, "REGISTER", "You can register.");
//SetupCharacter(playerid);
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration", "Fill your password into the box below", "Okay", "Cancel");
}
PHP Code:
case DIALOG_REGISTER:{
if(response){
if(!response) return Kick(playerid);
if(!strlen(inputtext) || strlen(inputtext) > 100){
System_Scm(playerid, COLOR_RED, "ERROR", "Password must be at least 5 words and lower than 100 words.");
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration", "Fill your password into the box below to register your account", "Ok", "Cancel");
}
else if(strlen(inputtext) > 0 && strlen(inputtext) < 100)
{
new pName[MAX_PLAYER_NAME], query[256];
new Cache:GetCache;
GetPlayerIp(playerid, Character[playerid][IP], 16);
mysql_format(MHandle, query, sizeof(query), "INSERT INTO `character` (`Username`, `Password`, `Level`, `Money`, `IP`, `posX`, `posY`, `posZ`, `posA`, `Health`, `Armour`) VALUES ('%s', 'SHA1(%s)', (1), (10000), '%s', (1958.3783), (1343.1572), (15.3746), (90.0), (100.0), (0.0))", pName, inputtext, Character[playerid][IP]);
GetCache = mysql_query(MHandle, query);
cache_delete(GetCache);
System_Scm(playerid, COLOR_YELLOW, "REGISTERED", "You have registered succesfully!");
SpawnPlayer(playerid);
}
}
}