MySQL Connect
#1

Hi guys.

I want to make a server with a MySQL connection.

I'm using this plugin: SA:MP MySQL Plugin

I got this now...

Includes & defines:
Код:
#include <mysql>

#define MYSQL_RESULT_LOGIN 1
#define MYSQL_RESULT_REGISTER 2
Other...
Код:
public OnGameModeInit()
{
	new MySQL:connection = mysql_init(LOG_ONLY_ERRORS, 1);
	mysql_connect("host", "username", "password", "database", connection);
	//I changed the host, username, password and database into default.
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    	mysql_close(connection);
    	return 1;
}
And this in the dialogcode:
Код:
mysql_query_array("SELECT * FROM `users` WHERE `username` = 'pName' LIMIT 0,1", MYSQL_RESULT_LOGIN, {playerid}, connection);
But the problem is that in the other pieces of code he doesn't know what "connection" is.

Errors:
Код:
C:\SAMP Server\Ultimate Stuntages\filterscripts\Zadmin1-MySQL.pwn(242) : error 017: undefined symbol "connection"
C:\SAMP Server\Ultimate Stuntages\filterscripts\Zadmin1-MySQL.pwn(282) : error 008: must be a constant expression; assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
If i put "new MySQL:connection = mysql_init(LOG_ONLY_ERRORS, 1);" in the defines, pawno will crash.

Help!
Reply
#2

pawn Код:
new MySQL:connection; // Declared with a global scope

connection = mysql_init(LOG_ONLY_ERRORS, 1); // Used inside a function/procedure
Reply
#3

What to do with this:

Код:
public OnMysqlQuery(resultid, spareid, MySQL:handle)
{
	switch (resultid)
	{
		case MYSQL_RESULT_LOGIN:
		{
			// process login with spareid as playerid
			SendClientMessage(spareid, COLOR_GREEN, "Succesfully logged in with MySQL!");
		}
		case MYSQL_RESULT_REGISTER:
		{
			// process register with spareid as playerid
		}
	}
	return 1;
}
It won't work! << Sorry, i'm new with this
Reply
#4

Got another plugin now, so i started a new topic.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)