[SQL] Usermanagement System
#1

Код:
	if(strcmp(cmd, "/register", true) == 0)
	{
	  MySQLCheck();
	  new query[256], name[256];
	  GetPlayerName(playerid, name, 256);
	  format(query, 256, "SELECT * FROM `users` WHERE `username`='%s'", name);
	  mysql_query(query);
	  mysql_store_result();
		if(mysql_num_rows() == 1)
		{
		  SendClientMessage(playerid, COLOR_RED, "ERROR: Your nickname is already registered! Please login! [/login]");
		  return 1;
		}
		
		new tmp[256];
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp))
		{
		  SendClientMessage(playerid, COLOR_RED, "ERROR: /register [password]");
		  return 1;
		}
		
		format(query, 256, "INSERT INTO `users` (`id`, `username`, `password`, `money`) VALUES(NULL, '%s', '%s', '10000');", name, tmp);
		mysql_query(query);
		SendClientMessage(playerid, COLOR_GREEN, "Registration Completed!");
		mysql_close();
		return 1;
	}
elsewhere

Код:
MySQLCheck()
{
	if(mysql_ping() == -1)
	{
		mysql_connect(host, user, database, password);
	}
	return 1;
}
The server has access to the database (as it is remote to where the server is hosted) but it seems to crash when it checks to see if their is a record, the database exists and the table exists, but their are no records - could that affect it?
Reply
#2

try turning debug on ( mysql_debug(1); ) and check mysql.log (or some file like that) in the server directory.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)