New at MySQL - 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: New at MySQL (
/showthread.php?tid=183388)
New at MySQL -
SloProKiller - 15.10.2010
Hello, I am converting my script from dini to MySQL. This is the first time I used MySQL.
Here is my connect code:
pawn Код:
forward ConnectMySQL();
public ConnectMySQL()
{
if(mysql_connect(SQL_HOST,SQL_USER,SQL_DB,SQL_PASS))
{
mysql_debug(1);
printf("[MYSQL]: Connection to `%s` succesful!",SQL_DB);
}
else
{
printf("[MYSQL]: [ERROR]: Connection to `%s` failed!",SQL_DB);
}
return 1;
}
That is called under GameModeInit.
Then, I have an IRC command called "!setmotd".
pawn Код:
CMD(setmotd)
{
if(IsOwner)
{
format(stri,sizeof(stri),"UPDATE `Vars` SET `params` = '%s' WHERE `variable` = 'MOTD'", params);
mysql_query(stri);
IRC_Say(gBotID, channel, "MOTD set.");
}
return 1;
}
And the actually command to get the "MOTD":
pawn Код:
CMD(motd)
{
mysql_query("SELECT * FROM `Vars` WHERE `variable` = 'MOTD'", 1);
format(stri, sizeof(stri), "MOTD is: %s");
IRC_Say(gBotID, channel, stri);
return 1;
}
I get errors in the MySQL log:
Код:
[13:50:50] >> mysql_query( Connection handle: 1 ) <- query called
[13:50:50] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead) <- query fail
[13:50:51] >> mysql_reconnect( Connection handle: 1 ) <- reconnect tried
[13:50:51] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection) <- reconnect fail
[13:50:51] CMySQLHandler::Connect() - Access denied for user '41_exotic'@'ks312869.kimsufi.com' (using password: YES) (Error ID: 1045) <- and fail again
Help would be appreciated,
-SloPro.
P.S. I know I fail at MySQL
Re: New at MySQL -
JaTochNietDan - 15.10.2010
It would appear that the username and/or password for the database are incorrect.
Try logging in using a MySQL client with the username and password and see if it works, if it doesn't you should re-check and confirm your MySQL server settings.
Re: New at MySQL -
SloProKiller - 15.10.2010
Nope, it won't connect either. I am sure I typed everything right so I guess it's the database's fault.
Re: New at MySQL -
Scenario - 15.10.2010
Oh, and I don't believe your MySQL syntax is correct.
pawn Код:
CMD:motd(playerid, params[])
That's how it should be done when using "CMD".
Quote:
Originally Posted by SloProKiller
Nope, it won't connect either. I am sure I typed everything right so I guess it's the database's fault.
|
Where is your database hosted?
Re: New at MySQL -
SloProKiller - 15.10.2010
Quote:
Originally Posted by RealCop228
Oh, and I don't believe your MySQL syntax is correct.
pawn Код:
CMD:motd(playerid, params[])
That's how it should be done when using "CMD".
Where is your database hosted?
|
(CMD) is defined. #define CMD(%1) IRCCMD:%1(botid, channel[], user[], host[], params[])
It is hosted at the server's host. I'll try hosting it at home now.
Re: New at MySQL -
Scenario - 15.10.2010
I would try doing a localhost both ways just for testing purposes.