[Plugin] [REL] SA:MP MySQL Plugin 2.1.1 - Released (1/25/2011

Is this a plugin error or just a mistake by me? I'm getting a error saying this:
Код:
MySQL Error (0): Function: 'mysql_fetch_row' called when no result stored.
The problem is with that is that, the result is stored. I put the code below in OnMysqlQuery. Please have a look into this!

Код:
mysql_store_result();
new vehiclestringsize[128], vehiclesplitting[24][128];
while(mysql_fetch_row(vehiclestringsize,"|")) {

 // My code...
}
Reply

Hello,
I've posted my question on the other plugin's topic without any answer so I'll post here too in hope for an answer
So, my question would be like this:

Does anyone know how to convert a non-threaded mysql function - script to a threaded one ?

Example:

Код:
public CheckVeh(carid, camp[], descriere[])
{
	new query[128];
	format(query, sizeof(query), "SELECT %s FROM veh WHERE ID = %d LIMIT 1",camp, carid);
	mysql_query(query);
	mysql_store_result();
	if(mysql_fetch_row(descriere))
	{
		mysql_free_result();
		return 1;
	}
	mysql_free_result();
	return 0;
}
Does anyone know how to write this function to use threaded query (OnQueryFinish) ?
Thanks.
Reply

2 things,
first: Is it possible that mysql_connect returns inversely?

when using this
Код:
	if(mysql_connect(SQL_HOST,SQL_USER,SQL_PASS,SQL_DB))
	{
		print("MySQL connected.");
		print("Registration System Loaded.");
	}
	else
	{
		print("MySQL has failed to connect.");
	}
It always returns MySQL has failed to connect., and then I go on to run querys in the rest of the script.

Second:

When using this addapted from menax's code
Код:
ZCMD:register(playerid,params[])
{
  new tmp[256], idx;
  tmp = strtok(params, idx);
  new string[256];
	if(Logged[playerid])
	{
		return SendClientMessage(playerid,COLOR_GREY,"You are already registered and logged in.");
	}
	if(IsRegistered(playerid))
	{
	  return SendClientMessage(playerid,COLOR_GREY,"You're already registered.");
	}
	if(isnull(tmp))
	{
	  return SendClientMessage(playerid,COLOR_GREY,"Usage: /register [password]");
 	}
 	
	mysql_escape_string(params,params);
	mysql_escape_string(pInfo[playerid][name],pInfo[playerid][name]);
	format(string,sizeof(string),"INSERT INTO players (Name,Password,kills,score,deaths,banned,cash,bank,level) VALUES ('%s','%s',0,0,0,0,0,0,0)",pInfo[playerid][name],params);
	query(string);
	SendClientMessage(playerid,COLOR_GREY,"Registered, user now use /login [password]");
	return 1;
}
the server always crashes, and the mysql log from the insert is (Error (0): Could not execute query. Unknown column 'iownafiretruck' in 'where clause'.) (iownafiretruck is the username), Im having a decent amount of trouble using the insert query with this plugin. Can anyone help?
Reply

Hey guys, I relize there are some bugs, I've fixed all of them that I know of, but I just haven't gotten a chance to upload it, and I'm having problems with the ftp.

I will try to release 1.2.1 ASAP.

Thanks,
Ethan
Reply

I have error on Ubuntu if one player login no problem but if 2 player login the server crash !

And i have 0 error on pwn compile

Excuse me for my bad english i am french !
Help me
Reply

Is there a max size for the string of the query..?
Reply

Quote:
Originally Posted by Double-O-Seven
Посмотреть сообщение
Is there a max size for the string of the query..?
I doubt there is, but I wouldn't try shooting for a high number, I'd say the largest for a query is 1012.

What size are you trying to use atm?
Reply

My starting query to create the data base is more than 4000 symbols long :X

There must be maybe 100 or more variables like "Kills" etc. be created in the table "Accounts".

I just don't know how to create them with more than 1 query :X So I put them all into 1 string/query :X

My code in OnGameModeInit
How can I create these variables without using only one query?
Reply

Quote:
Originally Posted by Double-O-Seven
Посмотреть сообщение
My starting query to create the data base is more than 4000 symbols long :X

There must be maybe 100 or more variables like "Kills" etc. be created in the table "Accounts".

I just don't know how to create them with more than 1 query :X So I put them all into 1 string/query :X

My code in OnGameModeInit
How can I create these variables without using only one query?
You don't need to create them like that, You can use wamp, which has phpmyadmin included, so you can create mysql database/tables/fields at ease.
Reply

Hi,

When I try to connect to the database in the OnGameModeInit() function, the server crashes when I try to join.
The server launches fine, and connects to the database successfully (well, at least that's what's being logged) but when I try to join the server... crash.

If I connect to the database in main(), it seems to work fine.

Am I doing something wrong, or...?
Reply

Anyone know which fuction i can use in this plugin to replace mysql_fetch_row_format(); from gstylez plugin? Is it mysql_fetch_row(); or is it somthing esle?
Reply

It is probably mysql_fetch_row (I don't know for the mysql_fetch_row_format function) because it allows you to set a delimiter like | when fetching a row, so for example lets say you have 'field' field in the 'table' and you would like to fetch them, it would look something like this.

Код:
mysql_query("SELECT * FROM `table` WHERE `field` = 'value';", MYSQL_RESULT_GET);
// OnMysqlQuery
if(resultid == MYSQL_RESULT_GET)
{
        new buffer[128];

        if(mysql_result_stored()) mysql_free_result();
        mysql_store_result();
        mysql_fetch_row(buffer);

        // buffer will be like Value1 | Value2

        if(mysql_result_stored()) mysql_free_result();
}
Reply

Nice one StrikenKid! I think I'll use it
Reply

Good Plugin Thanks i'll use this...
Reply

Does anyone have the plugin compatible with R8 that they could send me? Not the current version, the one before it.
Reply

Maybe this one works.

pawn Код:
format(GlobalQuery, sizeof(GlobalQuery), "SELECT * FROM `Houses` WHERE `Houseid` = '%d'",id);
print(GlobalQuery);
mysql_query(GlobalQuery);
mysql_store_result();
Reply

Try doing this
Код:
stock LoadGasstation()
{
	MySQLCheck();
	new idx;new data[256];

	mysql_query("SELECT * FROM gasstation");
	mysql_store_result();
	
        if(mysql_num_rows() > 0) 
        {
	        while(mysql_fetch_row(data))
	        {
		        GasInfo[idx][tID] = idx;

		        mysql_fetch_field("tGas",data);GasInfo[idx][tBenzin] = strval(data);
		        mysql_fetch_field("tPosX",data);GasInfo[idx][tPosX] = floatstr(data);
		        mysql_fetch_field("tPosY",data);GasInfo[idx][tPosY] = floatstr(data);
		        mysql_fetch_field("tPosZ",data);GasInfo[idx][tPosZ] = floatstr(data);
		
		        printf("ID: %d, Gas: %d, PosX: %f, PosY: %f, PosZ:    %f",GasInfo[idx][tID],Gas[idx][tGas],GasInfo[idx][tPosX],GasInfo[idx][tPosY],GasInfo[idx][tPosZ]);
		        idx++;
                }
	}
	
	mysql_free_result();
	return 1;
}
Reply

thx Luka, but the same problem like before. It only reads the first 14 out...
Reply

Try using this to see how many rows it thinks it should have.

Код:
stock LoadGasstation()
{
	MySQLCheck();
	new idx;new data[256];

	mysql_query("SELECT * FROM gasstation");
	mysql_store_result();
	
        if(mysql_num_rows() > 0) 
        {
                printf("There are %d results",mysql_num_rows());
	        while(mysql_fetch_row(data))
	        {
		        GasInfo[idx][tID] = idx;

		        mysql_fetch_field("tGas",data);GasInfo[idx][tBenzin] = strval(data);
		        mysql_fetch_field("tPosX",data);GasInfo[idx][tPosX] = floatstr(data);
		        mysql_fetch_field("tPosY",data);GasInfo[idx][tPosY] = floatstr(data);
		        mysql_fetch_field("tPosZ",data);GasInfo[idx][tPosZ] = floatstr(data);
		
		        printf("ID: %d, Gas: %d, PosX: %f, PosY: %f, PosZ:    %f",GasInfo[idx][tID],Gas[idx][tGas],GasInfo[idx][tPosX],GasInfo[idx][tPosY],GasInfo[idx][tPosZ]);
		        idx++;
                }
	}
	
	mysql_free_result();
	return 1;
}
and see if that reports the right number of results.
Reply

I have it now. The array GasInfo was on 14. But it has to be on 15!

(new GasInfo[14][GasData] --> new GasInfo[15][GasData])

thx for your help. But an other question

How can I do this better?

Код:
stock SaveGasstation()
{
    MySQLCheck();
    new query[MAX_STRING];new idx;
    while(idx < 15) //15 = max data in gasstation
    {
        format(query, MAX_STRING, "UPDATE gasstation SET tGas=%d,tPosX=%f,tPosY=%f,tPosZ=%f WHERE ID=%d",GasInfo[idx][tBenzin],GasInfo[idx][tPosX],GasInfo[idx][tPosY],GasInfo[idx][tPosZ],idx+1);
        mysql_query(query);
        idx++;
     }
     return 1;
}
Reply


Forum Jump:


Users browsing this thread: 18 Guest(s)