SA-MP Forums Archive
[SQL] Usermanagement System - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SQL] Usermanagement System (/showthread.php?tid=110320)



[SQL] Usermanagement System - Crazycamel - 25.11.2009

Код:
	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?


Re: [SQL] Usermanagement System - Think - 25.11.2009

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