27.02.2012, 08:07
Hi, I am currently Learning MySQL system But I am getting Problem , I am Storing field_row but on debug logs are
"CMySQLHandler::FetchField(userid) - You cannot call this function now. (Reason: Fields/Rows are empty.)" \
....
Here's The Code where this error is...
Debug Logs:
Whats wrong I do??
"CMySQLHandler::FetchField(userid) - You cannot call this function now. (Reason: Fields/Rows are empty.)" \
....
Here's The Code where this error is...
pawn Код:
case D_LOGIN:
{
if(response)
{
new query[128],query_run,P_Name[24],rows,escpass[24],data[24],tmpid;
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);
query_run = mysql_query(query);
mysql_store_result();
rows = mysql_num_rows(query_run);
if(rows == 1)
{
mysql_fetch_field_row(data, "userid"); tmpid = strval(data);
mysql_free_result();
format(query,sizeof(query),"Your Register ID is %d !",tmpid);//checking if working....
SendClientMessage(playerid, C_SKYBLUE, query);
SendClientMessage(playerid, C_SKYBLUE, "You have been logged in!");
IsLogged[playerid] = 1;
}
else if(rows == 0)
{
ShowPlayerDialog(playerid, D_LOGIN, DIALOG_STYLE_INPUT, "Login","Incorrect Password.\n Please enter your password again.","Login","Cancel");
SendClientMessage(playerid, C_RED, "Incorrect password!");
}
}
if(!response)
{
SendClientMessage(playerid, 0xFF0000, "You must login before you spawn!");
ShowPlayerDialog(playerid, D_LOGIN, DIALOG_STYLE_INPUT, "Login","Account Registered! Please login with your password below!\n You must login before you spawn!","Login","Cancel");
}
}
Код:
[14:05:10] --------------------------- [14:05:10] MySQL Debugging activated (02/27/12) [14:05:10] --------------------------- [14:05:10] [14:05:10] >> mysql_connect( ) [14:05:10] CMySQLHandler::Connect() - Connection was successful. [14:05:10] CMySQLHandler::Connect() - Auto-Reconnect has been enabled. [14:05:10] >> mysql_query( Connection handle: 1 ) [14:05:10] CMySQLHandler::Query(SELECT * FROM `p_data` WHERE username = 'Shabi' LIMIT 1) - Successfully executed. [14:05:10] >> mysql_store_result( Connection handle: 1 ) [14:05:10] CMySQLHandler::StoreResult() - Result was stored. [14:05:10] >> mysql_num_rows( Connection handle: 1 ) [14:05:10] CMySQLHandler::NumRows() - Returned 1 row(s) [14:05:10] >> mysql_free_result( Connection handle: 1 ) [14:05:10] CMySQLHandler::FreeResult() - Result was successfully free'd. [14:05:13] >> mysql_real_escape_string( Connection handle: 1 ) [14:05:13] CMySQLHandler::EscapeString(shahab); - Escaped 6 characters to shahab. [14:05:13] >> mysql_query( Connection handle: 1 ) [14:05:13] CMySQLHandler::Query(SELECT userid FROM `p_data` WHERE `username` = 'Shabi' AND password = 'shahab' LIMIT 1) - Successfully executed. [14:05:13] >> mysql_store_result( Connection handle: 1 ) [14:05:13] CMySQLHandler::StoreResult() - Result was stored. [14:05:13] >> mysql_num_rows( Connection handle: 1 ) [14:05:13] CMySQLHandler::NumRows() - Returned 1 row(s) [14:05:13] >> mysql_fetch_field_row( Connection handle: 1 ) [14:05:13] CMySQLHandler::FetchField(userid) - You cannot call this function now. (Reason: Fields/Rows are empty.) [14:05:13] >> mysql_free_result( Connection handle: 1 ) [14:05:13] CMySQLHandler::FreeResult() - Result was successfully free'd.