Hello Guys,
I begin with sourcepawn and i'm building a script for learning, my plugins is working fine, but now i try to use mysql, i can connecte but after is too hard for me.
I'm searching and reading all about "sourcepawn" and mysql but after many days without success i need help.
I juste want count if a user is existing in my base, like :
PHP Code:
SELECT COUNT(*) FROM transactions
for after do this :
PHP Code:
if (total == 0) {
do this
}
else {
do this
}
i found a litle code in the forum :
https://forums.alliedmods.net/showthread.php?t=262795
This is my code, it work but i got always "1":
PHP Code:
public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
char error[255];
Database db = SQL_DefConnect(error, sizeof(error));
if (db == null)
{
PrintToServer("Could not connect: %s", error);
}
else
{
///////////////////////////////////////////////////////////////
new Handle:db_RowCount = SQL_Query(db, "SELECT COUNT(*) FROM transactions");
new client = GetClientOfUserId(GetEventInt(event, "userid"));
//
new RowCount = SQL_GetFieldCount(db_RowCount);
PrintToChat(client, "\x01 \x04## %d ##", RowCount);
///////////////////////////////////////////////////////////////
}
}
i tryed the code, but me too i got always "1" on result, someone answer to must use "fetch" for the first row, i understand, but i don't know the "good" syntax for fetch the row...
i'm totally desperat, i'm trying since 4 days night and day (really) for learn, but here i'm lost !
Thanks for all help guys, i do my best i'm sorry but it's new for me