SA-MP Forums Archive
mysql Get String R7 problem - 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: mysql Get String R7 problem (/showthread.php?tid=368274)



mysql Get String R7 problem - Mellnik - 12.08.2012

I have this code but when i use it server crashes and the mysql_log says that the result was empty and that I cant call a function now:
BUT the field i wanna get is not empty!
Код:
stock mysql_GetString(Table[], Field[], Where[], Is[])
{
	new query[128], Get[128];
	mysql_real_escape_string(Table, Table);
	mysql_real_escape_string(Field, Field);
	mysql_real_escape_string(Where, Where);
	mysql_real_escape_string(Is, Is);
	format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
	mysql_function_query( gSQL , query , false , "" , "" );
	mysql_store_result();
 	mysql_fetch_row(Get);
	mysql_free_result();
	return Get;
}

Any Idea? I use R7 from BlueG



Re: mysql Get String R7 problem - phillip875 - 12.08.2012

How can it return Get, if you didn't format Get? lol

I would also use

mysql_fetch_field_format();

In this:

while(mysql_fetch_field_format(querystringhere,"|" ))
{
mysql_fetch_field_row(storestring,fieldname);
}


AW: Re: mysql Get String R7 problem - Mellnik - 12.08.2012

Quote:
Originally Posted by phillip875
Посмотреть сообщение
How can it return Get, if you didn't format Get? lol
And how would you do like?


Re: mysql Get String R7 problem - phillip875 - 12.08.2012

Try this:

pawn Код:
stock mysql_GetString(Table[], Field[], Where[], Is[])
{
    new query[128], Get[128];
    format(query, 128, "SELECT * FROM `%s` WHERE `%s` = '%s'", Table, Where, Is);
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(Get,field);
    }
    return Get;
}
CHANGED!


AW: mysql Get String R7 problem - Mellnik - 12.08.2012

But there is no query functio.

Shall I add mysql_function_query( gSQL , query , false , "" , "" );
under the format line?


Re: mysql Get String R7 problem - phillip875 - 12.08.2012

Nope.

while(mysql_fetch_row_format(query,"|")) is checking the query.

I'm giving you a different stock method which is easier for you.

If not, add mysql_query(query); before while(mysql_fetch_row_format))


Re: mysql Get String R7 problem - playbox12 - 12.08.2012

R7 has no support for unthreaded queries.

Please refer to this tutorial. https://sampforum.blast.hk/showthread.php?tid=337810


AW: Re: mysql Get String R7 problem - Mellnik - 12.08.2012

Quote:
Originally Posted by playbox12
Посмотреть сообщение
R7 has no support for unthreaded queries.

Please refer to this tutorial. https://sampforum.blast.hk/showthread.php?tid=337810
Oh thanks and another question: should i use 'mysql_real_escape_string' by an integer or only by strings?^^


Re: mysql Get String R7 problem - playbox12 - 12.08.2012

Only strings, an integer simply cannot contain statements SQL can intepret as an order. Only escape strings that can be altered by the user, any and all strings that is. Better be safe than sorry.