SA-MP Forums Archive
MySQL in OnPlayerConnect seems bugging - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL in OnPlayerConnect seems bugging (/showthread.php?tid=254577)



MySQL in OnPlayerConnect seems bugging - Jochemd - 11.05.2011

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


Re: MySQL in OnPlayerConnect seems bugging - [NoV]LaZ - 11.05.2011

Код:
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
}



Re: MySQL in OnPlayerConnect seems bugging - Laronic - 11.05.2011

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


Re: MySQL in OnPlayerConnect seems bugging - Jochemd - 11.05.2011

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


Re: MySQL in OnPlayerConnect seems bugging - [NoV]LaZ - 11.05.2011

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.


Re: MySQL in OnPlayerConnect seems bugging - Jochemd - 11.05.2011

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


Re: MySQL in OnPlayerConnect seems bugging - Laronic - 11.05.2011

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


Re: MySQL in OnPlayerConnect seems bugging - Jochemd - 11.05.2011

Actually I am not using a ; here at all.


Re: MySQL in OnPlayerConnect seems bugging - [NoV]LaZ - 11.05.2011

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.


Re: MySQL in OnPlayerConnect seems bugging - Jochemd - 11.05.2011

Where is that thing? Just wondering, sorry