21.05.2014, 16:36
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
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
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:
Thanks in regards,
Matt Tucker.
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;
}
pawn Код:
SELECT name FROM users WHERE name='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;
}
Matt Tucker.