New at MySQL
#1

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
Reply
#2

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.
Reply
#3

Nope, it won't connect either. I am sure I typed everything right so I guess it's the database's fault.
Reply
#4

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?
Reply
#5

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.
Reply
#6

I would try doing a localhost both ways just for testing purposes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)