Mysql Error , Need Quick Help - 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: Mysql Error , Need Quick Help (
/showthread.php?tid=315876)
Mysql Error , Need Quick Help -
Shabi RoxX - 04.02.2012
Hy, guys I am new in samp programming and currently working on MySQL..
My SQL connection is working but its not getting player data....
PHP код:
stock LoadAccount(playerid)
{
new query[128], P_Name[24], savingdata[20];
GetPlayerName(playerid, P_Name, sizeof(P_Name));
format(query, sizeof(query), "SELECT * FROM p_data WHERE username = '%s'", P_Name);
mysql_query(query);
mysql_store_result();
mysql_fetch_field_row(savingdata, "score"); SetPlayerScore(playerid, strval(savingdata));
mysql_fetch_field_row(savingdata, "money"); GivePlayerMoney(playerid,strval(savingdata));
mysql_fetch_field_row(savingdata, "adminlevel");P_Var[playerid][p_Adminlevel] = strval(savingdata);
mysql_free_result();
return 1;
}
MySQL DEBUG file....
Код:
[23:25:21] >> mysql_real_escape_string( Connection handle: 1 )
[23:25:21] CMySQLHandler::EscapeString(shahab); - Escaped 6 characters to shahab.
[23:25:21] >> mysql_query( Connection handle: 1 )
[23:25:21] CMySQLHandler::Query(SELECT userid FROM `p_data` WHERE `username` = 'G_Rana_G' AND password = 'shahab' LIMIT 1) - Successfully executed.
[23:25:21] >> mysql_store_result( Connection handle: 1 )
[23:25:21] CMySQLHandler::StoreResult() - Result was stored.
[23:25:21] >> mysql_query( Connection handle: 1 )
[23:25:21] CMySQLHandler::Query(SELECT userid FROM `p_data` WHERE `username` = 'G_Rana_G' AND password = 'shahab' LIMIT 1) - Successfully executed.
[23:25:21] >> mysql_num_rows( Connection handle: 1 )
[23:25:21] CMySQLHandler::NumRows() - Returned 1 row(s)
[23:25:21] >> mysql_query( Connection handle: 1 )
[23:25:21] CMySQLHandler::Query(SELECT score,money,adminlevel FROM p_data WHERE username = 'G_Rana_G') - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
[23:25:21] >> mysql_store_result( Connection handle: 1 )
[23:25:21] CMySQLHandler::StoreResult() - Result was stored.
[23:25:21] >> mysql_fetch_field_row( Connection handle: 1 )
[23:25:21] CMySQLHandler::FetchField(score) - You cannot call this function now. (Reason: Fields/Rows are empty.)
[23:25:21] >> mysql_fetch_field_row( Connection handle: 1 )
[23:25:21] CMySQLHandler::FetchField(money) - You cannot call this function now. (Reason: Fields/Rows are empty.)
[23:25:21] >> mysql_fetch_field_row( Connection handle: 1 )
[23:25:21] CMySQLHandler::FetchField(adminlevel) - You cannot call this function now. (Reason: Fields/Rows are empty.)
[23:25:21] >> mysql_free_result( Connection handle: 1 )
[23:25:21] CMySQLHandler::FreeResult() - Result was successfully free'd.
[23:25:21] >> mysql_free_result( Connection handle: 1 )
[23:25:21] CMySQLHandler::FreeResult() - The result is already empty.
Here
?
Код:
[23:25:21] CMySQLHandler::Query(SELECT score,money,adminlevel FROM p_data WHERE username = 'G_Rana_G') - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
[23:25:21] >> mysql_store_result( Connection handle: 1 )
[23:25:21] CMySQLHandler::StoreResult() - Result was stored.
[23:25:21] >> mysql_fetch_field_row( Connection handle: 1 )
[23:25:21] CMySQLHandler::FetchField(score) - You cannot call this function now. (Reason: Fields/Rows are empty.)
And Here MySQL is working for me....
PHP код:
case D_LOGIN:
{
if(response)
{
new query[128],P_Name[24],rows,escpass[24];
GetPlayerName(playerid,P_Name,sizeof(P_Name));
//GetPlayerIp(playerid,P_IP,sizeof(P_IP));
mysql_real_escape_string(inputtext, escpass);
format(query,sizeof(query),"SELECT userid FROM `p_data` WHERE `username` = '%s' AND password = '%s' LIMIT 1",P_Name,escpass);
mysql_query(query);
mysql_store_result();
rows = mysql_num_rows(mysql_query(query));
if(rows == 1)
{
LoadAccount(playerid);
SendClientMessage(playerid,C_WHITE,"Account Succesfully LoggedIn!");
GameTextForPlayer(playerid, "~g~WelCome Back!",500,1);
IsLogged[playerid] = 1;
mysql_free_result();
}
else { SendClientMessage(playerid,C_WHITE,"Wrong Password!"); }
}
else { SendClientMessage(playerid,C_WHITE,"Kicked :p!"); }
}
Re: Mysql Error , Need Quick Help -
Shabi RoxX - 04.02.2012
Any one , who can help me ??
Re: Mysql Error , Need Quick Help -
Shabi RoxX - 04.02.2012
*bump*