Raised This Month: $ Target: $400
 0% 

Solved A simple query for get total user in Mysql database


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
delux450
Junior Member
Join Date: Apr 2020
Old 04-20-2020 , 10:32   A simple query for get total user in Mysql database
Reply With Quote #1

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(errorsizeof(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

Last edited by delux450; 04-21-2020 at 06:27.
delux450 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode