MySQL Connect - 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: MySQL Connect (
/showthread.php?tid=248557)
MySQL Connect -
johannetje2 - 14.04.2011
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!
Re: MySQL Connect -
Conroy - 14.04.2011
pawn Код:
new MySQL:connection; // Declared with a global scope
connection = mysql_init(LOG_ONLY_ERRORS, 1); // Used inside a function/procedure
Re: MySQL Connect -
johannetje2 - 14.04.2011
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
Re: MySQL Connect -
johannetje2 - 16.04.2011
Got another plugin now, so i started a new topic.