![]() |
[Pawn] mysql - invalid row index '0' - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) --- Thread: [Pawn] mysql - invalid row index '0' (/showthread.php?tid=950) |
mysql - invalid row index '0' - Demo - 2019-12-13 Hello everyone, i created a similar mysql login/register system now like this example here:?https://github.com/pBlueG/SA-MP-MySQL/blob/master/example_scripts/login_system-cache.pwn The only thing i changed is: i dont assign default values after registering server side. I want to get them from db, since i added it there as defaults if a new player registers an account. How i did this is: if we assume the functions are all the same as the example above, i called? Code: AssignPlayerData(playerid) Code: public OnPlayerRegister(playerid) Login works fine, but if trying to "AssignPlayerData" after registration i get this error for every data i want to to get. Code: [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0') If im thinking right, this is because the entire query to get data is in OnPlayerConnect, and if account does not exists we have no row for that player. So do i need to do the same query again after registering the player and before "AssignPlayerData" ? Is this the right way, or is there a cleaner way? RE: mysql - invalid row index '0' - JustMichael - 2019-12-14 Show us the code for registration, else you can't really give you the right help. RE: mysql - invalid row index '0' - Demo - 2019-12-14 Check out the example i posted, it?s exactly the same RE: mysql - invalid row index '0' - JustMichael - 2019-12-14 it's quite clear what the issue is, you are trying to access the data returned from the query, when it doesn't exist. You are either missing a check, or you are calling `cache_get_value_name_int` too early. |