Mysql help
#1

Hello, i updated the mysql plugin from R5 to R39-3, I recompiled the gamemode and i have this error:
Code:
Copy\pawno\include\saveacc.inc(478 ) : error 035: argument type mismatch (argument 1)
Code:
format(var,100,"UPDATE `vehicles` SET `Ammo4`='%d' WHERE `CarID`='%d'",vInfo[vehicleid][trAmmo4],vInfo[vehicleid][vCariD]);
mysql_query(var);//this 478
mysql_query(var); This is the line with error.

What can i do?
Reply
#2

The first parameter in mysql_query for R33+ is the connection handle (which is returned by mysql_connect) and the query string is the second one (in your case var).

Also it's not exactly the same like updating and it will work. You need to modify it: https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_query

However, threaded queries are always better and faster to use.
Reply
#3

mysql_query needs atleast 2 arguments.

pawn Code:
native Cache:mysql_query(conhandle, query[], bool:use_cache = true);
That "conhandle" is a number representing the connection. mysql_connect returns that number..

pawn Code:
new gDbHandle;

public OnGameModeInit()
{
    gDbHandle = mysql_connect(stuff);
}

// And then when you want to use it:
// mysql_query(gDbHandle, query);

EDIT: aaanad I'm too slow.
Reply
#4

... I resolve that error but now appear this

error 017: undefined symbol "mysql_store_result"
error 017: undefined symbol "mysql_free_result"
error 017: undefined symbol "mysql_ping"
error 017: undefined symbol "mysql_fetch_row"
error 017: undefined symbol "mysql_num_rows"
error 017: undefined symbol "mysql_retrieve_row"
error 017: undefined symbol "mysql_fetch_field_row"
Reply
#5

Because those are old functions newer functions start with cache_ now.

https://sampwiki.blast.hk/wiki/MySQL/R33
Reply
#6

Those functions no longer exist in R39.

To upgrade from R5 to R39 you will need to re-write all your mysql related code.

I'll give you an example of both loading and saving.
pawn Code:
// R5 loading
mysql_real_escape_string(stringvariable, stringvariable);
format(query, sizeof(query), "SELECT stuff FROM table WHERE something = '%s'", stringvariable);
mysql_query(query);
mysql_store_result();
if(mysql_fetch_field_row(query))
{
      sscanf(query, "p<|>data"....);
}
mysql_free_result();

// R39 loading
mysql_format(connection_handle, query, sizeof(query), "SELECT stuff FROM table WHERE something = '%e'", stringVariable);
new Cache:result = mysql_query(connection_handle, query);
if(cache_get_row_count())
{
     cache_get_field_content(0, "string_column_name", stringVariable);
     printf("String variable:%s", stringVariable); // stringVariable will now hold a value from the column "string_column_name" from row 1.
     printf("int value:%d", cache_get_field_content_int(0, "int_column_name"));
     printf("Float value:%f", cache_get_field_content_float(0, "float_column_name"));
}
cache_delete(result);
Note that cache_get_field_content are NOT the only way to parse the result. Refer to wiki for more info.

pawn Code:
// R5 saving:
mysql_real_escape_string(something, soemthing);
format(query, sizeof(query), "UPDATE table SET int_column = %d, float_column = %f, string_column = '%s' WHERE something = %d", data, something);
mysql_query(query);
format(query, sizeof(query), "INSERT INTO table (int_column, float_column, string_column) VALUES(%d, %f, '%s')");
mysql_query(query);

// R39 saving:
mysql_format(connection_handle, query, sizeof(query), "UPDATE table SET int_column = %d, float_column = %f, string_column = '%e' WHERE something = %d", data, something);
mysql_pquery(connection_handle, query);

mysql_format(connection_handle, query, sizeof(query), "INSERT INTO table (int_column, float_column, string_column) VALUES(%d, %f, '%e')", values...);
mysql_pquery(connection_handle, query);

Check the wiki for mysql_pquery and mysql_tquery documentation.

AS you may have noticed mysql_real_escape_string is replaced by the %e specified in mysql_format.
Reply
#7

still is this error:

sorry but, not resemble each other, i can't find.

error 017: undefined symbol "mysql_store_result"
error 017: undefined symbol "mysql_free_result"
error 017: undefined symbol "mysql_ping"
error 017: undefined symbol "mysql_fetch_row"
error 017: undefined symbol "mysql_retrieve_row"
error 017: undefined symbol "mysql_fetch_field_row"
Reply
#8

These Function aren't exist in the new update
Here is some of them:
Code:
mysql_store_result = Nothing
mysql_free_result = cache_delete
mysql_ping = mysql_errno (Can be used to check for the database connection and other errors in the script which belong to mysql)
These are some which I know
Reply
#9

where can i find it?
Reply
#10

https://sampwiki.blast.hk/wiki/MySQL/R33
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)