SQL not retrieving - 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)
+--- Thread: SQL not retrieving (
/showthread.php?tid=590468)
SQL not retrieving -
austin070 - 29.09.2015
pawn Код:
public OnPlayerConnect(playerid)
{
PlayerInfo[playerid][Logged] = 0;
new query[128];
mysql_format(g_Handle, query, sizeof(query), "SELECT * FROM `users` WHERE `name` = '%e' LIMIT 1", GetPName(playerid));
mysql_tquery(g_Handle, query, "CheckPlayerExists", "i", playerid);
return 1;
}
pawn Код:
public CheckPlayerExists(playerid)
{
new rows, fields;
cache_get_data(rows, fields, g_Handle);
if(rows)
{
cache_get_field_content(0, "password", PlayerInfo[playerid][Password]);
printf("%s", PlayerInfo[playerid][Password]); //debug
print("Exists!); //debug
ShowLogin(playerid);
}
else
{
print("Does not exist."); //debug
ShowRegister(playerid);
}
return 1;
}
This is not retrieving the password from the database and I can't figure out why. I'm using blueG's r39-3 and recently converted to it so I guess I did something wrong. Can anyone correct me?
AW: SQL not retrieving -
Kaliber - 29.09.2015
Well..did you looked at your table..does this row really exist?
Re: SQL not retrieving -
austin070 - 29.09.2015
Yes, the row exists.
AW: SQL not retrieving -
Kaliber - 29.09.2015
Then print the query..and use phpmyadmin to find the mistake
or look in the mysql_debug
Re: SQL not retrieving -
austin070 - 29.09.2015
Код:
[15:26:22] [DEBUG] Calling callback "CheckPlayerExists"..
[15:26:22] [DEBUG] cache_get_data - connection: 1
[15:26:22] [DEBUG] cache_get_field_content - row: 0, field_name: "password", connection: 1, max_len: 1
[15:26:22] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "password", data: "hidden"
[15:26:22] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
This seems healthy to me
Re: SQL not retrieving -
PrO.GameR - 29.09.2015
When using MYSQL if you want to use strings in enums as a destination you need to provide the string length yourself
PHP код:
cache_get_field_content(0, "password", PlayerInfo[playerid][Password],1,30);
Where you should change 30 to fit the size of Password in your playerinfo enum
Re: SQL not retrieving -
austin070 - 29.09.2015
Quote:
Originally Posted by PrO.GameR
When using MYSQL if you want to use strings in enums as a destination you need to provide the string length yourself
PHP код:
cache_get_field_content(0, "password", PlayerInfo[playerid][Password],1,30);
Where you should change 30 to fit the size of Password in your playerinfo enum
|
Thank you.