MySQL Help! - 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 Help! (
/showthread.php?tid=148703)
MySQL Help! -
NewTorran - 18.05.2010
Im a sort of beginner at MySQL,
Anyway im using StrickenKid's MySQL plugin,
I have this ( My friend gave me it ) to for a register:
pawn Код:
CMD:test1(playerid, params[])
{
new string[256];
format(string,sizeof(string),"INSERT INTO `users` (`username`, `password`) VALUES ('%s', '%s')", GetName(playerid), params);
mysql_query(string);
return 1;
}
And ingame when i type that command, It sends this to my server console:
Quote:
Originally Posted by Server Console
MySQL Error <0>: Function 'mysql_query' called when not connected to any database, Access denied for user 'root'@'password' <using password: YES>
|
But when i loaded the FS it successfully connected to mysql
Re: MySQL Help! -
Steven82 - 18.05.2010
Well Torran, i am stumped.....shit i used to know SQL too, but then i starting scripting roleplay's and i stoped using SQL and now i suck at it. Sorry i couldn't help
:/
Re: MySQL Help! -
NewTorran - 18.05.2010
Quote:
Originally Posted by Steven82
Well Torran, i am stumped.....shit i used to know SQL too, but then i starting scripting roleplay's and i stoped using SQL and now i suck at it. Sorry i couldn't help
:/
|
Lol? Anyway if anyone knows why it says it successfully connects upon gamemode init and then when someone tries to register it says it cannot connect
Re: MySQL Help! -
Sergei - 18.05.2010
Ask in plugin's topic. And read some articles about SQL injection because your command is just made for that.
Re: MySQL Help! -
Anwix - 18.05.2010
before running the query check if you are still connected to the database.
Код:
CMD:test1(playerid, params[])
{
if (mysql_ping())
{
new string[256];
format(string,sizeof(string),"INSERT INTO `users` (`username`, `password`) VALUES ('%s', '%s')", GetName(playerid), params);
mysql_query(string);
SendClientMessage(playerid, 0xFFFFFFFF, "Connected and query success!");
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "You are not connected to the database!");
}
return 1;
}
Re: MySQL Help! -
NewTorran - 18.05.2010
This is very confusing as i tried again and it says it connects successfully and then when i type the command it says it cant do mysql_whatever because im not connected to a database!
Re: MySQL Help! -
Anwix - 18.05.2010
You can quickly fix it by using functions with each query that will check if you are connected still.
Код:
stock MySQL()
{
if (!mysql_ping())
{
print("Reconnecting to database.");
mysql_connect(hostname, username, database, password);
MySQL(); // this will just execute the function to check again.
}
}
Код:
CMD:test1(playerid, params[])
{
MySQL();
new string[256];
format(string,sizeof(string),"INSERT INTO `users` (`username`, `password`) VALUES ('%s', '%s')", GetName(playerid), params);
mysql_query(string);
return 1;
}
Re: MySQL Help! -
Onyx09 - 18.05.2010
Quote:
Originally Posted by Steven82
Well Torran, i am stumped.....shit i used to know SQL too, but then i starting scripting roleplay's and i stoped using SQL and now i suck at it. Sorry i couldn't help
:/
|
Omg you such a spamer i been seen many post about you know Php html and now SQL and presume your a god at it but cant help at all?
you earned your report
Re: MySQL Help! -
NewTorran - 18.05.2010
Ok so i finally got the hang of MySQL, After all this i ended up using Adrenaline DJ's plugin/include :P
Re: MySQL Help! -
Sergei - 18.05.2010
Quote:
Originally Posted by Joe Torran C
Ok so i finally got the hang of MySQL, After all this i ended up using Adrenaline DJ's plugin/include :P
|
You fell really low.