(R39-6) 'invalid row index ('0')'
#1

http://i.imgur.com/UPRY7L0.png
^
Here is a link to the mySQL error log.

Explanation: I can register on the server and everything will be perfect. No issues. However, When I log out and log back in I begin falling from the sky and I put some debug comments in the script and I found out that my [pSQLID] = 0 so it isn't loading any of the proper information for that specific account. The username and password to log in works fine, But it seems the issue is I'm not assigning the [pSQLID] to the player data during the login process. Or that may just be a result of a bigger issue. Let me just link you my code.

PHP код:
        case DIALOG_LOGIN:
        {
            if(!
response) return Kick(playerid);
            if(
strlen(inputtext) < || strlen(inputtext) > 30) {
                
ShowLoginDialog(playerid"Password length must be at least 3 characters and below 30 characters.");
                return 
true;
            }
            new 
query[128];
            
mysql_format(sqlConnectionquerysizeof(query), "SELECT id FROM players WHERE Name = '%e' AND Password = sha1('%e') LIMIT 1"GetName(playerid), inputtext);
            
mysql_pquery(sqlConnectionquery"SQL_OnAccountLogin""i"playerid);
        } 
PHP код:
Server:SQL_OnAccountLogin(playerid)
{
    if(
cache_num_rows() == 0){
        
ShowLoginDialog(playerid"Incorrect Password.");
        return 
true;
    }
    
    
SendClientMessage(playeridCOLOR_WHITE"You have successfully logged in.");
//debug    
    
new string[128];
    
format(stringsizeof(string), "* Your SQL id is: %i"PlayerData[playerid][pSQLID]);
    
SendClientMessage(playeridCOLOR_WHITEstring);
//debug end
    
LoadPlayerData(playerid);
    return 
true;

PHP код:
ServerSQL_OnLoadAccount(playerid)
{
    
LoggedIn[playerid] = true;
    
PlayerData[playerid][pSQLID] = cache_get_field_content_int(0"id"sqlConnection);
    
PlayerData[playerid][pAdminLevel] = cache_get_field_content_int(0"AdminLevel"sqlConnection);
    
PlayerData[playerid][pMoney] = cache_get_field_content_int(0"Money"sqlConnection);
    
PlayerData[playerid][pLevel] = cache_get_field_content_int(0"Level"sqlConnection);
    
PlayerData[playerid][pRespect] = cache_get_field_content_int(0"Respect"sqlConnection);
    
PlayerData[playerid][pLastPos][0] = cache_get_field_content_float(0"LastX"sqlConnection);
    
PlayerData[playerid][pLastPos][1] = cache_get_field_content_float(0"LastY"sqlConnection);
    
PlayerData[playerid][pLastPos][2] = cache_get_field_content_float(0"LastZ"sqlConnection);
    
PlayerData[playerid][pLastPos][3] = cache_get_field_content_float(0"LastRot"sqlConnection);
    
PlayerData[playerid][pLastInt] = cache_get_field_content_int(0"Interior"sqlConnection);
    
PlayerData[playerid][pLastWorld] = cache_get_field_content_int(0"World"sqlConnection);
    
SetPlayerScore(playeridPlayerData[playerid][pLevel]);
    
ResetPlayerMoney(playerid); GivePlayerMoney(playeridPlayerData[playerid][pMoney]);
    
SetPlayerSpawn(playerid);
    return 
true;

PHP код:
Server:LoadPlayerData(playerid)
{
    new 
query[255];
    
mysql_format(sqlConnectionquerysizeof(query), "SELECT * FROM players WHERE id = %i LIMIT 1"PlayerData[playerid][pSQLID]);
    
mysql_pquery(sqlConnectionquery"SQL_OnLoadAccount""i"playerid);
    return 
true;

I would really appreciate if you could spare a few minutes to help me solve my issues.
Thanks again, I appreciate any help.
Reply
#2

Has it worked prior, or did you just add some of the other portions, such as the save location, as that blueberry is usually 0 0 0, and in there it says about the wrong format being in the table. They should be floats.
Reply
#3

first of all you have to forward password here too !
PHP код:
mysql_pquery(sqlConnectionquery"SQL_OnAccountLogin""is"playerid,password);
Server:SQL_OnAccountLogin(playerid,password)
//and ... 
and second is you dont need limit while you define a key like id for players in tables :S (as i know)

PHP код:
"SELECT * FROM players WHERE id = %i LIMIT 1" 
and third try to delete your results to avoid memory leaks
PHP код:
cache_delete(); 
and then make sure you defined colum as FLOAT type and your varbs in player stats as FLOAT to

PHP код:
ALTER TABLE table
ADD Pos FLOAT
;
//and
Float:pLastPos
and then show us your SetPlayerSpawn & your enums too plz
Reply
#4

http://i.imgur.com/bhE2Ug2.png
Here is the structure of my database. They are set up for Float.

PHP код:
Server:SetPlayerSpawn(playerid)
{
    
SetSpawnInfo(playerid0DEFAULT_SKINPlayerData[playerid][pLastPos][0], PlayerData[playerid][pLastPos][1], PlayerData[playerid][pLastPos][2], PlayerData[playerid][pLastPos][3], 000000);
    
SpawnPlayer(playerid);
    
SetPlayerVirtualWorld(playeridPlayerData[playerid][pLastWorld]);
    
SetPlayerInterior(playeridPlayerData[playerid][pLastInt]);
    return 
true;

PHP код:
enum PLAYER_DATA
{
    
pSQLID,
    
pAdminLevel,
    
pMoney,
    
pLevel,
    
pRespect,
    
Float:pLastPos[4],
    
pLastInt,
    
pLastWorld


Thank you for taking the time to help me solve this. I'm fairly new to mySQL and this was my first big project on my own. Obviously I need some guidance though.
Reply
#5

Something to help you pinpoint this error may be to print the output to the console when the script loads it. Then maybe you could see what it's loading, and what it's saving by also doing the same on the save function.

Use printf to push it out to the log with all the values you're wanting to check.
Reply
#6

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Something to help you pinpoint this error may be to print the output to the console when the script loads it. Then maybe you could see what it's loading, and what it's saving by also doing the same on the save function.

Use printf to push it out to the log with all the values you're wanting to check.
i think his problem is saving float in string type and getting again saving it as float in mysql

dude use
PHP код:
Float:pLastPosx,
Float:pLastPosy,
Float:pLastPosz,
Float:pLastPosr
im sure it will fix your problem
Reply
#7

When your debug message gets sent ("Your SQL id is ...") then nothing has been assigned yet so obviously that will show 0. Then you call LoadPlayerData and since we just established that the the id is 0 you also query for id 0. Control then transfers to SQL_OnLoadAccount where you try to fetch a row that doesn't exist.

You need to actually fetch the id before sending the message and before calling LoadPlayerData.
Reply
#8

Quote:
Originally Posted by Vince
Посмотреть сообщение
When your debug message gets sent ("Your SQL id is ...") then nothing has been assigned yet so obviously that will show 0. Then you call LoadPlayerData and since we just established that the the id is 0 you also query for id 0. Control then transfers to SQL_OnLoadAccount where you try to fetch a row that doesn't exist.

You need to actually fetch the id before sending the message and before calling LoadPlayerData.
This is what I needed.
Thank you very much man! I got it fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)