PDA

View Full Version : undefined symbol


Face9000
25/03/2017, 12:46 AM
I'm using Blueg's MYSql R41-2 and i have this code:

public OnLoginDate(extraid, username[])
{
if (!IsPlayerConnected(extraid))
return 0;

static
rows,
fields,
date[36];

cache_get_data(rows, fields, g_SQL);

if (rows) {
cache_get_row(0, 0, date, g_SQL);

new buf[128];
format(buf, sizeof(buf), "%s's last login was on: %s", username,date);
SendClientMessage(extraid,COLOR_RED, buf);
}
else {
SendClientMessage(extraid,COLOR_RED, "Invalid username specified.");
}
return 1;
}

That gives me:


error 017: undefined symbol "cache_get_data"
error 017: undefined symbol "cache_get_row"

Also in this stock:

stock SQL_ReturnEscaped(const string[])
{
new
entry[256];

mysql_real_escape_string(string, entry, g_iHandle);
return entry;
}

Always undefined symbol mysql_real_escape_string.

X337
25/03/2017, 05:28 AM
cache_get_data, cache_get_row and mysql_real_escape_string aren't MySQL R41-2 functions.
You can use cache_get_row_count to get total rows, cache_get_value_* to get field values, and mysql_escape_string or use %e specifier in mysql_format to escape string.

Sibuscus
25/03/2017, 08:23 AM
new rows;
cache_get_row_count(rows);
if(rows)....

Check this link for more details, it helped me enormously: http://forum.sa-mp.com/showthread.php?t=616103

Face9000
25/03/2017, 08:59 PM
public OnLoginDate(extraid, username[])
{
if (!IsPlayerConnected(extraid))
return 0;

static
rows,
fields,
date[36];

cache_get_value(rows, fields, g_SQL);

if (rows) {
cache_get_row_count(0, 0, date, g_SQL);

new buf[128];
format(buf, sizeof(buf), "%s's last login was on: %s", username,date);
SendClientMessage(extraid,COLOR_RED, buf);
}
else {
SendClientMessage(extraid,COLOR_RED, "Invalid username specified.");
}
return 1;
}

Same.

AndySedeyn
26/03/2017, 12:12 AM
You've got a few things wrong:
cache_get_row_count(&destination)
Takes only a single function argument. Usage:

new
rows;

cache_get_row_count(rows);



All of these can be found on the wiki, by the way: http://wiki.sa-mp.com/wiki/MySQL/R40

I by accident removed half of my post, but cache_get_value is used to retrieve a value from the result query set and not the row count.