SA-MP Forums Archive
No rows returned with MySQL plugin - 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)
+--- Thread: No rows returned with MySQL plugin (/showthread.php?tid=345837)



No rows returned with MySQL plugin - C0b0ll - 26.05.2012

Hello erverybody ,

I use the MySQL plugin by G-sTyLeZzZ (https://sampforum.blast.hk/showthread.php?tid=56564).

I try to load a player from my data base, but no rows are returned...

My load function :
Код:
	new query[STRING_SIZE];
	format(query, sizeof(query), "SELECT * FROM g_player WHERE name like '%s'", Player[playerid][pSqlName]);
	mysql_store_result();
	
	new data[50];
	
	if(mysql_fetch_row_format(data))
	{
		new fieldStr[SQL_VARCHAR_SIZE];
		mysql_get_field("id", fieldStr);                            // Id
		Player[playerid][pSqlId] = strval(fieldStr);
		mysql_get_field("email", Player[playerid][pSqlEmail]);      // Email
 	}
	else
		{printf("ERROR : player_load : loading '%s'.", Player[playerid][pSqlName]);}

	// Debugging
	printf("data = %s", data);
 	printf("id = %d", Player[playerid][pSqlId]);
 	printf("email = %s", Player[playerid][pSqlEmail]);
 	
	mysql_free_result();
	return true;
What i'm doing wrong ?

Tanks a lot !


Re: No rows returned with MySQL plugin - Vince - 26.05.2012

You're not even sending the query.


Re: No rows returned with MySQL plugin - Mandrakke - 26.05.2012

pawn Код:
format(query, sizeof(query), "SELECT * FROM g_player WHERE name like '%s'", Player[playerid][pSqlName]);
mysql_query(query);
mysql_store_result();

Also I recommend you to use BlueG's plugin.


Re : No rows returned with MySQL plugin - C0b0ll - 27.05.2012

Hello,

Tanks for your replies .

I didn't copy correctly my code, I forgot the mysql_query(query);.

In fact, the script crash on this line :
Код:
mysql_get_field("email", Player[playerid][pSqlEmail]);
I try this code too :
Код:
mysql_get_field("email", fieldStr);                			// Email
format(Player[playerid][pSqlEmail], SQL_VARCHAR_SIZE, fieldStr);
What i'm doing wrong ?

Thanks a lot again


Re: Re : No rows returned with MySQL plugin - MP2 - 27.05.2012



Quote:
Originally Posted by C0b0ll
Посмотреть сообщение
Tanks for your replies .
?

Use mysql_fetch_field_row instead:

pawn Код:
mysql_fetch_field_row(Player[playerid][pSqlEmail], "email"); // I THINK mySQL is case sensitive, so 'email' is not the same as 'Email'. Not sure though.



Re : Re: Re : No rows returned with MySQL plugin - C0b0ll - 27.05.2012

Hi,

"Thanks", with the H of Rhino .

Quote:
Originally Posted by MP2
Посмотреть сообщение
pawn Код:
mysql_fetch_field_row(Player[playerid][pSqlEmail], "email"); // I THINK mySQL is case sensitive, so 'email' is not the same as 'Email'. Not sure though.
MySQL isn't and my email field is named "email".

Thanks


Re : No rows returned with MySQL plugin - C0b0ll - 27.05.2012

There is my code :

Код:
	new query[STRING_SIZE];
    mysql_real_escape_string(password, password);
	format(query, sizeof(query), "SELECT * FROM %s WHERE name LIKE '%s' AND password = MD5('%s')", SQL_TBL_PLAYER, Player[playerid][pSqlName], password);
	mysql_query(query);
	mysql_store_result();

	new data[STRING_SIZE];
	if(!mysql_fetch_row_format(data))
	{
		mysql_free_result();
		return false;
	}
	
	new fieldStr[SQL_VARCHAR_SIZE];

	mysql_get_field("id", fieldStr);
	Player[playerid][pSqlId] = strval(fieldStr);

	mysql_get_field("Email", fieldStr); // <---------------------------- Crash here
	format(Player[playerid][pSqlEmail], SQL_VARCHAR_SIZE, fieldStr);

	mysql_free_result();
	return true;
An other stupid mistake ?

+