[Plugin] [REL] MySQL Plugin (Now on github!)

Quote:
Originally Posted by xcasio
Is there any reason as to why mysql_reconnect() returns the following: (two attempts)

[22:52:46] >> mysql_reconnect( Connection handle: 0 )
[22:52:46] >> mysql_reconnect() - Invalid connection handle. (You set: 0, Highest connection handle ID is 0).
[22:52:46] >> mysql_reconnect( Connection handle: 1 )
[22:52:46] >> mysql_reconnect() - Invalid connection handle. (You set: 1, Highest connection handle ID is 0).
You haven't even connected at the first place?

Quote:
Originally Posted by cAMo
What is the most effective way to UPDATE mysql from over 100 PVar's?
How would you structure it?
Depends. I'm sure at least 3/4 of those PVars aren't being changed frequently or aren't changed at all, so I would update them when they change.
Reply

Quote:
Originally Posted by $ЂЯĢ
Quote:
Originally Posted by xcasio
Is there any reason as to why mysql_reconnect() returns the following: (two attempts)

[22:52:46] >> mysql_reconnect( Connection handle: 0 )
[22:52:46] >> mysql_reconnect() - Invalid connection handle. (You set: 0, Highest connection handle ID is 0).
[22:52:46] >> mysql_reconnect( Connection handle: 1 )
[22:52:46] >> mysql_reconnect() - Invalid connection handle. (You set: 1, Highest connection handle ID is 0).
You haven't even connected at the first place?
I have, decided to just use mysql_connect if it's dead (which if often is due to filterscripts often being reloaded).


[00:37:33] CMySQLHandler::ProcessQueryThread(UPDATE `players` SET `last_online` = NOW(), `admin_level` = 0 WHERE `id` = 72, Resultid: 1) - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)

Any why this didn't get called in OnQueryFinish? Happens once an hour or so.
Reply

If you use mysql_close then it's obvious you can't use mysql_reconnect.
Reply

Quote:
Originally Posted by $ЂЯĢ
If you use mysql_close then it's obvious you can't use mysql_reconnect.
Is that what happens when a filterscript is unloaded? There is no documentation on this anywhere.

_________________________________________________

Quote:

[00:37:33] CMySQLHandler::ProcessQueryThread(UPDATE `players` SET `last_online` = NOW(), `admin_level` = 0 WHERE `id` = 72, Resultid: 1) - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)

With a load of 150+ players threaded queries sometimes do not get called in OnQueryFinish. Any idea what the problem could be?


Thanks.
Reply

1. Do you use mysql_close() under OnFilterscriptExit?
2. How many different threads did you use? It's possible that you went over mysql server's connection limit.
Reply

How do i select something (Done):

pawn Код:
new string[256];
format(string,sizeof(string),"SELECT `password` FROM `users` WHERE `username` = '%s'", GetName(playerid));
mysql_query(string);
And then how do i check if thats the same as what the player typed?
Reply

You don't do it like that.
pawn Код:
new string[128];
mysql_real_escape_string(password,password);
format(string,sizeof(string),"SELECT * FROM users WHERE username='%s' AND password='%s' LIMIT 1", GetName(playerid),password);
mysql_query(string);
If query gets any result then password was corrent and if it's doesn't it wasn't. I also suggest you to use MD5 hash (if you don't hash passwords with anything else).
Код:
SELECT * FROM users WHERE username='%s' AND password=MD5('%s') LIMIT 1
And I also suggest you to use threads for all queries for better performance.
Reply

Why are you erm MD5 hashing it?
Reply

Quote:
Originally Posted by Joe Torran C
Why are you erm MD5 hashing it?
Protection? Nobody wants his/her password to be displayed.
Reply

Quote:
Originally Posted by $ЂЯĢ
Quote:
Originally Posted by Joe Torran C
Why are you erm MD5 hashing it?
Protection? Nobody wants his/her password to be displayed.
Its not showing there password to anybody, Its seeing if it matches what they typed
Reply

Field (password): 4555c0928f443107d66461f99af5c756 (md5 hashed)
Now someone's input is 'mypass555'. If you want to compare you need to hash it of course.
Reply

No because when i create the account i dont hash the password
Reply

Quote:
Originally Posted by Joe Torran C
No because when i create the account i dont hash the password
You should do that. I don't think that your players would like that you (or anyone else) see their passwords in plain text.
Reply

Quote:
Originally Posted by $ЂЯĢ
Quote:
Originally Posted by Joe Torran C
No because when i create the account i dont hash the password
You should do that. I don't think that your players would like that you (or anyone else) see their passwords in plain text.
Ok well does anyone know any tutorials or anything to teach me how to make a creating/getting/updating thing for this
Because i tried with this one tutorial and its not a very good one, Anyone help? Thanks

Like it shows me how to create, get and update and explains what it is ect
Reply

Visit w3schools to learn about basic MySQL commands. And also, aren't you using StrickenKid's MySQL plugin?
Reply

Quote:
Originally Posted by $ЂЯĢ
Visit w3schools to learn about basic MySQL commands. And also, aren't you using StrickenKid's MySQL plugin?
Im trying everyones MySQL plugin, See which one i can get to work

Also: http://w3schools.com/sql/default.asp
That the one?

[b]I HAVE FINALLY GOT SOME OF IT TO WORK!

pawn Код:
public MySQLRegister(playerid, password[])
{
    new query[256];
  format(query, sizeof(query), "INSERT INTO `users` (userid, username, password) VALUES(0, \"%s\", \"%s\")", GetName(playerid), password);
    samp_mysql_query(query);
    return 1;
}

CMD:register(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, colorRed, "Usage: /register [password]");
   
    MySQLRegister(playerid, params);
    return 1;
}
Now for the login and il be on my way!
Reply

You should use ''''''''''''' not """""""""""""". Plus you should escape string to avoid sql injections.
Reply

Quote:
Originally Posted by $ЂЯĢ
You should use ''''''''''''' not """""""""""""". Plus you should escape string to avoid sql injections.
Huh? XD
Anyway i got my register and login to work
Reply

Quote:
Originally Posted by $ЂЯĢ
1. Do you use mysql_close() under OnFilterscriptExit?
2. How many different threads did you use? It's possible that you went over mysql server's connection limit.
Hi,

I do not use mysql_close() in the OnFilterScriptExit callback, however from testing I have observed that the connection is automatically closed when a filterscript is unloaded.

As for the amount of threads, I am currently just bringing in MySQL into the script, so there are only 3 threaded queries, 2 of which are called frequently. There are also a few non-threaded queries which are also called frequently.


Thank you for your help.
Reply

Show how frequently you trigger them, what those functions do, etc.
Reply


Forum Jump:


Users browsing this thread: 10 Guest(s)