mysql Get String R7 problem
#1

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
Reply
#2

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);
}
Reply
#3

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

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!
Reply
#5

But there is no query functio.

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

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))
Reply
#7

R7 has no support for unthreaded queries.

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

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?^^
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)