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=267910)
MySQL help -
[IL]HeHu - 10.07.2011
It just wouldn't connect to my MySQL, it drops the connection and closes the server.
This is how I fetch my server into the MySQL server:
PHP код:
mysql_connect("127.0.0.1", "root", "roleplay", "acciara123");
Maybe you got any idea what could it be?
Re: MySQL help -
Vince - 10.07.2011
All of the parameters could be wrong. It's your database, so you should know what the username, password and database name is.
Re: MySQL help -
[IL]HeHu - 10.07.2011
from what I know it's right, I mean the PHPmyadmin loads and all, so I really don't know what's the problem.
Re: MySQL help -
[NoV]LaZ - 10.07.2011
Check your logs made by the plugin.
Re: MySQL help -
[IL]HeHu - 10.07.2011
I did, the mysql log doesn't even recall the connection.
But the server log writes this:
PHP код:
[17:09:23] * SQL: Connection seems dead, retrying...
[17:09:23] * SQL: Could not reconnect to server, terminating server..
This is called because of my MySQLCheckConnection function.
Re: MySQL help -
[NoV]LaZ - 10.07.2011
Show your MySQLCheckConnection function. You must say what plugin are you using.
Re: MySQL help -
[IL]HeHu - 10.07.2011
Forget it, I fixed that problem myself, but now I have a new one

When I try and get information from the SQL db and place it into one of my variables thats what it writes:
PHP код:
[Sun Jul 10 18:59:02 2011] Error (0): Function: mysql_store_result called when no prior successful query executed.
[Sun Jul 10 18:59:02 2011] Error (0): Function: mysql_store_result called when no result stored.
How did I try and get and put:
PHP код:
PlayerInfo[playerid][pJob] = mysql_Int(SQL_USERS,PlayerInfo[playerid][pUID],"job");
mysql_Int function is something I built:
PHP код:
stock mysql_Int(table[],id,key[])
{
return strval(mysql_Get(table,id,key));
}
mysql_Get:
PHP код:
stock mysql_Get(table[],id,key[])
{
Query("SELECT `%s` FROM `%s` WHERE `userid` = '%d'",key,table,id);
new Result[30];
mysql_fetch_row_format(Result);
return Result;
}
mysql_fetch_row_format:
PHP код:
#define mysql_fetch_row_format(%1) mysql_fetch_row(%1,"|")
Query:
PHP код:
new F = false;
#if defined Query
#else
#define Query(%1,%2) do { new formatStr[256]; format(formatStr,sizeof(formatStr),%1,%2); if(SQL_Connection) mysql_query(formatStr); mysql_store_result(); } while(F)
#endif
#pragma unused F
I use StrickenKid's plugin and all the mysql_Get & mysql_Int are inside the "mysql.inc" file.
Re: MySQL help -
[NoV]LaZ - 10.07.2011
-edit-
Re: MySQL help -
[IL]HeHu - 10.07.2011
so would this work?
PHP код:
stock mysql_Get(table[], id,key[])
return Query("SELECT `%s` FROM `%s` WHERE `userid` = '%d'",key,table,id);
Re: MySQL help -
[IL]HeHu - 10.07.2011
Up...