MySQL system (BlueG's R5)
#1

I know that R5 is not that recent release but I just started off with MySQL a few days ago, after watching tutorials about the SQL thing itself, queries, tables, rows, databases...etc I decided to try to make a simple log/register gamemode to check the my understanding/like a self-test.

So, here's the code
pawn Код:
public OnPlayerConnect(playerid)
{
    if(mysql_ping()) print("MySQL connection is still alive!"); // self explanatory
    if(!mysql_ping()) print("MySQL connection is dead!"); //    ^

//  new query[126]; // just ignore this query for now
//  format(query,sizeof(query), "SELECT name FROM users WHERE name = '%s'", GetName(playerid));
    mysql_query("SELECT name FROM users WHERE name = 'his'");
    mysql_store_result();
    if(mysql_num_rows() == 1)
    {
        SendClientMessage(playerid,-1, "You are registered.");
    }
    else
    {
        SendClientMessage(playerid,-1, "Doesn't exist.");
    }
    return 1;
}
Okay so I have the mysql_connect under OnGameModeInit, mysql_close under OnGameModeExit and I have the users table and created a new row for "his" as a name, and when I run
pawn Код:
SELECT name FROM users WHERE name='his'
on the SQL query it runs perfectly fine and returns the column name having 'his'

The problem is, when I login into the game after hosting the GM, it says "Doesn't Exist", I thought it was something with the query that I formated, decided to try a normal one like name = 'his' after it worked on the sql query (phpmyadmin one) and yet still fails. So I kinda need help with mysql_store_results and mysql_num_rows on how to use/advices..etc


EDIT:I have the mysql_ping check on OnPlayerSpawn, OnPlayerRequestSpawn,OnplayerConnect OnPlayerDisconnect and it says connection it is alive.

EDIT#2:
pawn Код:
stock GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    return name;
}
Thanks in regards,
Matt Tucker.
Reply


Messages In This Thread
MySQL system (BlueG's R5) - by MattTucker - 21.05.2014, 16:36
Re: MySQL system (BlueG's R5) - by MacT - 21.05.2014, 17:54
Re: MySQL system (BlueG's R5) - by MattTucker - 22.05.2014, 11:32
Re: MySQL system (BlueG's R5) - by MacT - 22.05.2014, 12:04
Re: MySQL system (BlueG's R5) - by MattTucker - 22.05.2014, 12:11
Re: MySQL system (BlueG's R5) - by MacT - 22.05.2014, 12:13
Re: MySQL system (BlueG's R5) - by MattTucker - 22.05.2014, 12:15
Re: MySQL system (BlueG's R5) - by rappy93 - 22.05.2014, 12:18
Re: MySQL system (BlueG's R5) - by MacT - 22.05.2014, 12:25
Re: MySQL system (BlueG's R5) - by MattTucker - 22.05.2014, 12:39

Forum Jump:


Users browsing this thread: 3 Guest(s)