MySQL in OnPlayerConnect seems bugging
#1

Hello,

I've decided to switch from dini to MySQL cause of it's inefficiently. I need to learn whole MySQL and it's pretty hard for me. Now I got a problem in OnPlayerConnect.

pawn Код:
public OnPlayerConnect(playerid)
{
    new Playername[MAX_PLAYER_NAME],QueryString[128];
    GetPlayerName(playerid,Playername,sizeof(Playername));
    format(QueryString,sizeof(QueryString),"SELECT * FROM 'PlayerInfo' WHERE 'Account' = '%s'",Playername);
    mysql_query(QueryString);
    mysql_store_result();
    if(mysql_num_rows() != 0) SendClientMessage(playerid,-1,"Your name is registered, please use /login.");
    else if(mysql_num_rows() == 0) SendClientMessage(playerid,-1,"Your name is not registered, please use /register.");    
    return 1;
}
Picture which may come usefull

Somehow it always gives "Your name is registered, please use /login.". However, all rows are null. Even if I fill the rows with my account name, and some random stats it gives this message. Why is this?

My connection to the MySQL Database it fine, though. Hope at an answer soon!

Jochem
Reply
#2

Код:
SELECT * FROM `PlayerInfo` WHERE `Account` = '%s';
If you only have one condition, use else, not else if.

pawn Код:
if (mysql_num_rows() != 0)
{
    // we're registered
}
else
{
    // we're not registered
}
Reply
#3

Quote:
Originally Posted by [NoV]LaZ
Посмотреть сообщение
Код:
SELECT * FROM `PlayerInfo` WHERE `Account` = '%s';
If you only have one condition, use else, not else if.

pawn Код:
if (mysql_num_rows() != 0)
{
    // we're registered
}
else
{
    // we're not registered
}
pawn Код:
SELECT * FROM `PlayerInfo` WHERE `Account` = '%s'
remove the ; :P
Reply
#4

The condition with else doesn't matter, actually it's there cause I tried it this way later... It was the good way before

That ; is in the script of the guy above here, he typed it
Reply
#5

Quote:
Originally Posted by CyberGhost
Посмотреть сообщение
pawn Код:
SELECT * FROM `PlayerInfo` WHERE `Account` = '%s'
remove the ; :P
Apparently, you have no idea regarding MySQL syntax.

@Jochemd: ' is for the data and ` for the tables, columns, etc.
Reply
#6

Okay, well that is what I said in the start... I am new to this all.
Reply
#7

Quote:
Originally Posted by [NoV]LaZ
Посмотреть сообщение
Apparently, you have no idea regarding MySQL syntax.

@Jochemd: ' is for the data and ` for the tables, columns, etc.
I dont use the ; and it works fine for me! And you is acctually the 1st person i see who use it
i use Strickenkid's plugin
Reply
#8

Actually I am not using a ; here at all.
Reply
#9

Quote:
Originally Posted by Jochemd
Посмотреть сообщение
Actually I am not using a ; here at all.
Hint: If something is not working, always check your MySQL log file.
Reply
#10

Where is that thing? Just wondering, sorry
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)